Understanding the compression savings calculator — concept and principle
This calculator estimates how much smaller a file becomes when you switch on text compression (Gzip or Brotli) or convert JPEG images to WebP or AVIF, and how much monthly bandwidth that saves across your traffic. Site owners use it to justify enabling compression on a server or CDN, or to size the payoff of an image-format migration.
How it is calculated
- New size (KB) = original size × (1 − saving fraction).
- Monthly bandwidth saved (GB) = original size × saving fraction × monthly page views ÷ 1,000,000.
The method menu sets a typical saving fraction: Gzip on text 0.70, Brotli on text 0.76, JPEG to WebP 0.30, JPEG to AVIF 0.50. Dividing KB by one million gives GB in decimal units (1 GB = 1,000,000 KB).
The principle
Text formats such as HTML, CSS, JavaScript and JSON repeat the same words and patterns many times. Gzip uses the DEFLATE algorithm, which replaces repeated strings with short back-references (LZ77) and then encodes symbols with Huffman codes, so frequent symbols take fewer bits. Brotli uses a similar idea with a larger window, context modelling and a built-in dictionary of common web strings, so it usually beats Gzip on text by some extra percent. Images are different: JPEG is already compressed, so the savings from WebP and AVIF come from better prediction and transform coding at similar visual quality. AVIF, based on the AV1 video codec, generally compresses further than WebP but is slower to encode. Compression is lossless for Gzip and Brotli; image conversions are usually lossy and depend on the quality setting.
Worked example
- Inputs: 500 KB file, Gzip on text (0.70), 100,000 page views per month.
- New size: 500 × (1 − 0.70) = 500 × 0.30 = 150 KB.
- Saved per view: 500 × 0.70 = 350 KB.
- Monthly saving: 350 × 100,000 ÷ 1,000,000 = 35 GB.
| Original size (KB) | New size (KB) |
|---|---|
| 125 | 37.5 |
| 250 | 75 |
| 375 | 112.5 |
| 500 | 150 |
| 625 | 187.5 |
| 750 | 225 |
| 1,000 | 300 |
How to read the result
The saving fractions are typical, not guaranteed. Minified JavaScript often compresses 60–80%; already-compressed files (JPEG, PNG, MP4, ZIP, WOFF2) gain almost nothing from Gzip and should not be re-compressed. For images, test a few representative files at your chosen quality, because photos, screenshots and illustrations behave very differently.
Common mistakes
- Applying Gzip savings to images or video that are already compressed.
- Counting each page view as downloading the full file even when browsers or a CDN cache it.
Frequently asked questions
Is Brotli always better than Gzip?
For text it is usually somewhat smaller at comparable settings, and all modern browsers support it over HTTPS; Gzip remains a safe fallback.
Does compression slow down the server?
Compressing on the fly costs CPU, which is why static assets are often pre-compressed at high levels and stored.
Will WebP or AVIF reduce image quality?
Lossy conversion discards some detail; at sensible quality settings the difference is usually hard to see, but check sharp edges and text.
Sources: IETF RFC 1951 (DEFLATE) and RFC 1952 (GZIP file format) · IETF RFC 7932, Brotli Compressed Data Format · Alliance for Open Media, AV1 Image File Format (AVIF) specification