Gzip Compression Ratio Benchmarks by File Type

See gzip compression ratio benchmarks for HTML, CSS, JavaScript, JSON, XML, SVG, and other web file types. Data-driven comparison table.

Optimization

Detailed Explanation

Compression Benchmarks by File Type

Different file types compress at very different rates. This reference provides real-world benchmarks to help you estimate compressed transfer sizes.

Text-Based Web Assets

File Type Typical Ratio (Gzip) Typical Ratio (Brotli) Notes
HTML 70–80% 75–85% Tag repetition helps greatly
CSS 80–88% 83–90% Highly repetitive syntax
JavaScript 65–75% 70–80% Minified JS compresses less
JSON 75–90% 80–92% Key repetition in arrays
XML 75–85% 80–88% Tag names repeat heavily
SVG 70–80% 75–85% XML-based, compresses well
Plain text 60–70% 65–75% Less structured patterns
CSV 70–80% 75–85% Header names repeat in some formats
YAML 65–75% 70–80% Indentation helps compression

Already-Compressed Formats

File Type Gzip Ratio Worth Compressing?
JPEG 0–2% No
PNG 0–1% No (already DEFLATE)
WebP 0–1% No
WOFF2 0–1% No (already Brotli)
WOFF 2–5% Marginal
MP4 0–1% No
ZIP 0–1% No

What Drives Compression Ratios

The key factors that determine how well content compresses:

  1. Repetition density: More repeated patterns = better compression
  2. Alphabet size: Fewer unique characters = better Huffman coding
  3. Pattern proximity: Patterns within 32 KB window compress best
  4. Content entropy: Random/encrypted data does not compress

Practical Application

When estimating transfer sizes for performance budgets:

  • CSS budget: Multiply your raw CSS size by 0.15 (85% compression)
  • JS budget: Multiply your minified JS by 0.30 (70% compression)
  • HTML budget: Multiply your rendered HTML by 0.25 (75% compression)
  • JSON budget: Multiply your JSON by 0.15 (85% compression)

Use Case

Performance budget planning and web performance estimation. Use these benchmarks to predict transfer sizes without needing to actually compress every file during the planning phase.

Try It — Gzip Size Calculator

Open full tool