April 3, 2026 2 min readUpdated Apr 9, 2026
GZIP Compression Explained: How to Shrink Your Data
gzipcompressionperformancewebdevops

What Is GZIP?
GZIP is a lossless data compression format based on the DEFLATE algorithm (LZ77 + Huffman coding). It's the most widely used compression format on the web, reducing the size of text-based resources before they're sent over the network.
Typical Compression Ratios
| File Type | Original | GZIP'd | Savings |
|---|---|---|---|
| HTML | 120 KB | 28 KB | ~77% |
| CSS | 80 KB | 18 KB | ~78% |
| JavaScript | 250 KB | 75 KB | ~70% |
| JSON (API) | 40 KB | 9 KB | ~78% |
| PNG image | 100 KB | 98 KB | ~2% |
Images are already compressed — don't bother applying GZIP to them.
Enabling GZIP in Web Servers
Nginx
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml;
gzip_min_length 1000;
gzip_comp_level 6;
Apache (.htaccess)
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json
</IfModule>
Node.js (Express)
const compression = require('compression');
app.use(compression());
Vercel / CDN
Most CDN providers (Vercel, Cloudflare, Fastly) apply GZIP or Brotli automatically. Check response headers:
content-encoding: gzip
GZIP vs Brotli vs Zstandard
| Format | Compression | Speed | Browser Support |
|---|---|---|---|
| GZIP | Good | Fast | Universal |
| Brotli | ~20% better than GZIP | Slower | Modern browsers |
| Zstandard | Best (tunable) | Very fast | Limited (server-side) |
For static web assets, Brotli is now recommended if your server supports it.
Compression Levels
GZIP supports levels 1–9:
- Level 1 — fastest, least reduction
- Level 6 — good balance (nginx default)
- Level 9 — smallest file, slowest to compress
Check If Your Site Uses GZIP
curl -H "Accept-Encoding: gzip" -I https://example.com
# Look for: content-encoding: gzip
Compress and Decompress Files Online
Use the free GZIP Compress / Decompress tool on konvertio.app — paste your text or JSON, compress it instantly, and see the exact byte savings.