Gzip vs Brotli Compression: Which to Use for Your Web Server
Brotli compresses 15-25% smaller than Gzip for text content but is slower to compress. When to serve Brotli, when Gzip, and how to configure both correctly.
The short answer
Serve Brotli to browsers that accept it, with Gzip fallback. Brotli compresses static assets 15-25% smaller than Gzip at equivalent speed; the gap widens for HTML/CSS/JS. Decompression speed is comparable for both — the user doesn't feel a difference.
Compression ratios on real content
| Content | Raw | Gzip -9 | Brotli -11 |
|---|---|---|---|
| React bundle | 1,000 KB | 280 KB | 220 KB |
| HTML article | 80 KB | 20 KB | 16 KB |
| Tailwind CSS (full) | 3,500 KB | 420 KB | 320 KB |
| JSON API response (1 MB) | 1,000 KB | 180 KB | 150 KB |
| Already-compressed (JPEG) | 400 KB | 398 KB | 398 KB |
Compression speed matters for dynamic content
Brotli level 11 (maximum) can take 100× longer to compress than Gzip level 6. For static assets (CSS/JS bundles) you compress once at build time and serve forever — use maximum level. For dynamic content (API responses compressed on the fly), use Brotli level 4-5 or Gzip level 4-6; anything higher costs more server CPU than it saves bandwidth.
Configuration pitfalls
- Don't compress already-compressed content — JPEG, PNG, WebP, MP4, zip files. They gain nothing and cost CPU.
- Vary: Accept-Encoding is essential when serving different encodings to different clients. Without it, intermediary caches can serve the wrong encoding.
- Pre-compress static assets — generate
.brand.gzfiles at build time; configure the server to serve them directly instead of recompressing each request. - CDNs handle this for you — Cloudflare, CloudFront, Fastly all support Brotli automatically. Often simpler than configuring your origin.
Browser support (2026)
- Brotli — 97% global; anything except very old browsers
- Gzip — 100%; unchanged since 1997
What about Zstandard?
Zstandard (zstd) is Facebook's compression algorithm with better speed/ratio tradeoffs than Brotli for some workloads. HTTP support is emerging (Chrome, Firefox have flags) but not yet production-ready for public-facing sites. For now: Brotli for static, Gzip fallback, keep an eye on zstd.
Minify BEFORE compressing
Compression is not a substitute for minification. A minified JS file compresses to a smaller Brotli output than an un-minified one of the same compressed size, because minification eliminates redundancy the compressor can't. Use JavaScript minifier, CSS minifier, HTML minifier, and JSON minifier as a build step — then let Brotli/Gzip finish the job.
Measurable impact
Switching a typical 500 KB static bundle from Gzip to Brotli saves ~50-80 KB per user. At a million requests per month that's 50-80 GB of bandwidth, plus a real reduction in Time To First Byte for users on slow connections. LCP often improves 50-150ms on the first page load.
Featured Tools
Try these free related tools directly in your browser — no sign-up required.
JSON Minifier
Minify and compress JSON by removing whitespace and comments. Reduce JSON payload size instantly for faster API responses and smaller storage footprint.
CSS Minifier
Minify and compress CSS code instantly online. Remove whitespace, comments, and redundant code to reduce CSS file size and improve page load speed.
JavaScript Minifier
Minify and compress JavaScript code online. Remove whitespace, comments, and shorten variable names to reduce JS bundle size and improve load time.
HTML Minifier
Minify HTML by removing whitespace, comments, and optional tags. Reduce HTML document size to improve page load speed and server response times.