Compression Ratio Calculator
Inputs
| Original size | 100 MB |
|---|---|
| Compressed size | 25 MB |
Compression Ratio Calculator
Enter the original and compressed file sizes to find the compression ratio, space savings percentage, and absolute bytes saved. Works for any file type or compression algorithm.
Inputs
File Sizes
Results
Enter a value to see results.
Compression Results
Savings Detail
Compression Ratio
Compression ratio measures how effectively a compression algorithm reduces data volume. It appears in contexts ranging from archive utilities and network protocols to codec evaluation and database storage planning.
The formulas
CR=ScSo Space saved (%)=(1−SoSc)×100where is the original (uncompressed) size and is the compressed size, both in the same unit. A ratio greater than 1 means the file shrank; equal to 1 means no change.
Worked example. A 100 MB log archive compresses to 25 MB with gzip:
CR=25 MB100 MB=4(4:1) Space saved=(1−10025)×100=75%Ratio conventions
Two conventions are in common use. The one used here — original ÷ compressed — gives a number greater than 1, which is easier to compare at a glance (a ratio of 10 is clearly better than a ratio of 4). Some tools and papers use the reciprocal (compressed ÷ original, also called the compression factor or coding gain), which is a number between 0 and 1. Always check which convention a tool uses before comparing figures.
Typical ratios by file type
| File type | Algorithm | Typical ratio |
|---|---|---|
| Plain text, logs | gzip | 4:1 – 10:1 |
| Source code | gzip | 3:1 – 6:1 |
| Database dump | gzip | 5:1 – 15:1 |
| Photographs | JPEG (quality 80) | 10:1 – 20:1 |
| Audio | MP3 (128 kbps) | ~10:1 |
| Video | H.264 vs. uncompressed | 50:1 – 200:1 |
| Encrypted / random data | any lossless | ~1:1 |
Lossless versus lossy
Lossless compression (ZIP, FLAC, PNG, LZ4) guarantees that decompression reconstructs the original byte-for-byte. It is limited by the data's statistical redundancy — the Shannon entropy sets a theoretical minimum that cannot be beaten. Lossy compression (JPEG, MP3, H.264) permanently discards information judged imperceptible to human senses, breaking through the entropy floor at the cost of quality.
The entropy limit
Claude Shannon's source coding theorem (1948) proves that no lossless coder can compress an independent identically distributed source below its entropy. For a file of random bytes — such as the output of a cryptographically secure random-number generator or an already-encrypted file — the entropy equals the file size. Any lossless algorithm applied to such a file will produce output the same size as or larger than the input.
Related calculators
To estimate the raw uncompressed size of an image before compression, use the Image File Size Calculator calculator. To measure how long a compressed file takes to transfer, use the Download Time Calculator calculator.
Frequently Asked Questions (FAQ)
What does the compression ratio mean?
The compression ratio is original size divided by compressed size. A ratio of 3 means the compressed file is one-third as large as the original — it uses 3 bytes of original data for every 1 byte it stores. A ratio of 1 means no compression occurred. Some sources define ratio the other way (compressed ÷ original, giving a value less than 1), so always check the convention when comparing ratios from different tools.
What is the difference between lossless and lossy compression?
Lossless compression (ZIP, FLAC, PNG) reconstructs the original file exactly; the compression ratio is limited by the data's statistical redundancy and typically reaches 2:1 to 5:1 for typical files. Lossy compression (JPEG, MP3, H.264) permanently discards information to achieve much higher ratios — 10:1 to 100:1 — at the cost of some quality loss. The "best" approach depends on whether exact reproduction is required.
What compression ratios should I expect?
Plain text compresses well because of repeated patterns: ZIP achieves 3:1 to 6:1 on typical documents. Database dumps of repetitive data can reach 10:1 or higher. Photographs compressed as JPEG (quality 80) typically reach 10:1 to 20:1 compared to an uncompressed bitmap. Already-compressed formats like JPEG or MP4 gain little from further lossless compression — ratios near 1:1 are normal.
Is there a theoretical limit to compression?
Yes. Claude Shannon's source coding theorem (1948) states that no lossless algorithm can compress data below its Shannon entropy — a measure of the information content. For a file of completely random bytes the entropy equals the file size: further lossless compression is impossible and any algorithm will actually expand the output. This is why encrypted or already-compressed files refuse to shrink further with ZIP or gzip.