DevBolt
Processed in your browser. Your data never leaves your device.

Compression Ratio Guide: Measuring & Optimizing

A compression ratio measures how much an algorithm reduces data size. A ratio of 0.30 means the compressed output is 30% of the original size (70% savings). Understanding compression ratios helps you make informed decisions about web server configuration, CDN settings, and asset optimization.

← Back to tools

Brotli / Gzip Compression Tester

Test and compare Brotli, Gzip, and Deflate compression ratios for your text content. See which algorithm gives the best compression for your data.

About Compression Testing

  • Brotli — developed by Google, typically achieves 15-25% better compression than Gzip for text content. Supported by all modern browsers via HTTPS.
  • Gzip — the most widely supported compression format. Based on DEFLATE algorithm. Universally supported by web servers and browsers.
  • Deflate — the underlying algorithm used by both Gzip and Zlib. Lower overhead than Gzip (no header/trailer), but less common as a standalone format.
  • Compression ratios vary by content type — repetitive text like JSON and HTML compresses well (70-90% savings), while already-compressed or random data may not compress at all.
  • Everything runs in your browser — Gzip and Deflate use the native CompressionStream API, Brotli uses brotli-wasm. No data is sent over the network.

How Compression Ratios Are Calculated

Compression ratio = compressed size / original size. A ratio of 0.25 means the data was compressed to 25% of its original size. Savings percentage = (1 - ratio) x 100, so a 0.25 ratio means 75% savings. Lower ratios indicate better compression. The theoretical minimum depends on the data's entropy — truly random data cannot be compressed below its entropy.

What Affects Compression Ratios

Content type has the biggest impact: structured text (JSON, HTML, XML) compresses extremely well (70-90% savings) due to repeated patterns and keywords. Minified code compresses less well than formatted code. Already-compressed data (images, videos, ZIP files) sees near-zero improvement. Content length matters too — very short strings (under 100 bytes) may actually grow after adding compression headers.

Optimizing for Better Compression

For web assets: enable both Brotli and Gzip on your server, pre-compress static assets at maximum quality, and use lower quality levels for dynamic content. Consider the compression-speed tradeoff: Brotli quality 11 is best for pre-compression, while quality 1-4 suits real-time compression. For APIs returning JSON, consider minifying JSON output (removing whitespace) before compression.

Frequently Asked Questions

What is a good compression ratio for web content?

For text-based web content (HTML, CSS, JS, JSON), a good compression ratio is 0.15-0.35 (65-85% savings). Highly repetitive content like log files can achieve ratios below 0.10 (90%+ savings). If your ratio is above 0.50, the content may already be compressed or contain little redundancy.

Can compression make files larger?

Yes. Very small files (under ~150 bytes) or already-compressed content can actually grow after compression because the compression format adds headers and metadata. Most web servers have a minimum size threshold (often 1KB) below which they skip compression.

Does minification affect compression ratios?

Minification reduces the absolute file size, but compressed minified files are only slightly smaller than compressed unminified files. This is because compression algorithms already eliminate the redundancy that whitespace and long variable names create. Still, minification helps because it reduces the pre-compression size that the server must process.

Related Inspect Tools