Brotli vs Gzip — Which Compression Is Better?
Compare Brotli and gzip compression: speed, ratio, browser support, and when to use each. See real-world benchmarks for HTML, CSS, and JS.
Detailed Explanation
Brotli vs Gzip: A Comprehensive Comparison
Brotli (Content-Encoding: br) is a newer compression algorithm developed by Google. It often achieves better compression ratios than gzip, but the tradeoffs are nuanced.
Compression Ratio Comparison
Typical compression ratios for web assets:
| Content Type | Gzip (level 6) | Brotli (level 6) | Brotli (level 11) |
|---|---|---|---|
| HTML | 70–75% | 75–80% | 80–85% |
| CSS | 80–85% | 83–88% | 87–90% |
| JavaScript | 65–75% | 70–78% | 75–82% |
| JSON | 75–85% | 80–88% | 85–92% |
Brotli typically achieves 15–25% smaller output than gzip at comparable speed settings.
Speed Comparison
- Gzip level 6: ~100–200 MB/s compression speed
- Brotli level 6: ~50–100 MB/s (roughly 2x slower)
- Brotli level 11: ~2–5 MB/s (extremely slow, only for static pre-compression)
Browser Support
As of 2025, Brotli is supported by 97%+ of global browsers. The only notable exceptions are very old browsers (IE 11, Opera Mini). All modern browsers send Accept-Encoding: br, gzip, deflate by default.
When to Use Which
| Scenario | Recommendation |
|---|---|
| Static assets (build-time) | Brotli level 11 — best ratio, speed irrelevant |
| Dynamic responses (API) | Gzip level 6 — fast enough for real-time |
| CDN with edge compression | Brotli level 4–6 — good balance |
| Legacy browser support needed | Gzip as fallback |
Key Insight
The biggest wins come from pre-compressing static assets at build time with Brotli level 11. This gives you maximum compression without any runtime cost, since the compressed files are generated once and served many times.
Use Case
CDN configuration decisions, build pipeline setup, and server configuration. Understanding the tradeoffs helps you choose the right compression strategy for static vs dynamic content.