CalcEngine All Calculators

Compression Ratio Calculator

Data & Formats

Enter your original and compressed file sizes to instantly calculate the compression ratio and space savings. Works with ZIP, gzip, Brotli, zstd, and any other format.

Last updated: April 2026

This calculator is designed for real-world usage based on typical engineering scenarios and publicly available documentation.

The compression ratio calculator tells you exactly how effective a compression algorithm is by comparing original and compressed file sizes. Enter both sizes in the same unit — bytes, KB, MB, or GB — and you get the ratio, space savings percentage, and total size reduction. Compression ratio matters whenever storage cost or transfer time is on the line. DevOps engineers use it to evaluate gzip vs Brotli for web assets. Data engineers compare zstd vs Snappy for columnar storage. Backend teams measure payload compression before and after adding Content-Encoding: gzip to an API response. A ratio of 4:1 means the compressed file is four times smaller than the original — one quarter the storage space and one quarter the bandwidth cost. Typical ratios range from 1.5:1 for already-compressed media files to 10:1 or higher for repetitive text like logs or JSON. This calculator works for any lossless or lossy format. For lossy compression (JPEG, MP3, H.264), the ratio reflects file-size reduction but not quality trade-offs — factor in quality settings separately.

How to Calculate Compression Ratio

Compression Ratio — how it works diagram

1. Measure the original file size before compression — in bytes, KB, MB, or GB. 2. Compress the file using your chosen algorithm (gzip, zstd, Brotli, etc.). 3. Measure the compressed file size in the same unit. 4. Divide the original size by the compressed size to get the compression ratio. 5. Subtract the compressed size from the original and divide by the original to get space savings percentage.

Formula

Compression Ratio  = Original Size ÷ Compressed Size
Space Savings (%)  = (Original Size − Compressed Size) ÷ Original Size × 100
Size Reduced By    = Original Size − Compressed Size

Original Size    — file size before compression (any consistent unit)
Compressed Size  — file size after compression (same unit)
Ratio            — expressed as X:1; higher means better compression

Example Compression Ratio Calculations

Example 1 — gzip on a JSON API response

Original:    48,320 bytes (47.2 KB uncompressed JSON)
Compressed:   4,210 bytes (4.1 KB with gzip level 6)

Compression Ratio  = 48,320 ÷ 4,210  = 11.48:1
Space Savings      = (48,320 − 4,210) ÷ 48,320 × 100  = 91.3%
Size Reduced By    = 44,110 bytes saved per response

Example 2 — zstd on a CSV data export

Original:   512 MB (raw CSV log file)
Compressed:  68 MB (zstd level 3)

Compression Ratio  = 512 ÷ 68  = 7.53:1
Space Savings      = (512 − 68) ÷ 512 × 100  = 86.7%
Size Reduced By    = 444 MB saved — cuts S3 storage bill by 86.7%

Example 3 — JPEG image (already lossy-compressed)

Original:   2,400 KB (raw PNG screenshot)
Compressed:   180 KB (JPEG at 80% quality)

Compression Ratio  = 2,400 ÷ 180  = 13.33:1
Space Savings      = (2,400 − 180) ÷ 2,400 × 100  = 92.5%
Size Reduced By    = 2,220 KB — significant page-weight saving for web delivery

Tips to Maximise Compression Efficiency

Notes

Frequently Asked Questions

What is a good compression ratio? +
For plain text, JSON, and log files, a good ratio is 5:1 to 15:1. HTML and CSS typically compress to 3:1–8:1. Binary formats like databases reach 2:1–4:1. Already-compressed media (JPEG, MP4, ZIP) rarely exceeds 1.1:1. If you're seeing ratios below 1.5:1 on text data, inspect whether the data is already encoded in base64 or otherwise inflated.
Does compression ratio depend on file size? +
Yes — small files compress poorly because compression algorithms need enough repetition to build an efficient dictionary. A 1 KB JSON object may compress to 0.8:1 (no gain), while a 100 MB JSON dataset of similar structure can hit 8:1 or higher. For network payloads under ~1 KB, compression overhead often exceeds the savings.
How does compression ratio affect bandwidth cost? +
Directly — a 5:1 ratio cuts egress data volume by 80%, so a $100/month bandwidth bill drops to roughly $20. Cloud providers charge per GB transferred, so a higher compression ratio translates proportionally to lower bills. Use the Bandwidth Cost Calculator to model the exact dollar impact for your traffic volume.
What is the difference between compression ratio and space savings? +
They measure the same thing differently. A 4:1 ratio means the file is 4× smaller. Space savings is (1 − 1/ratio) × 100 = 75%. A 2:1 ratio equals 50% savings; 10:1 equals 90% savings. Use ratio when comparing algorithms head-to-head; use percentage when explaining storage or bandwidth reduction to stakeholders.
Can I compare compression ratio across different algorithms? +
Yes — compress the same input file with each algorithm and plug both results into this calculator. Compare ratios directly. Also consider CPU cost: zstd at level 3 often beats gzip level 6 in ratio and runs 3–5× faster. For a full picture, pair ratio with decompression latency, especially for read-heavy workloads like serving static files or reading from object storage.