Glossary
DEFLATE
The lossless compression behind half the web
By Buğra SözeriPublished Updated
DEFLATE is a lossless data compression algorithm specified in RFC 1951. It combines two techniques: LZ77 (finding repeated substrings and replacing them with back-references) and Huffman coding (assigning shorter binary codes to more common symbols).
DEFLATE is the compression algorithm behind PNG image files, ZIP archives, gzip-compressed files (including HTTP Content-Encoding: gzip), zlib library data streams, and Git’s pack files. It’s arguably the most-deployed compression algorithm in computing history.
Characteristics:
- Lossless — original bytes recoverable exactly.
- Fast to decompress, moderately fast to compress.
- No external dictionary, so any DEFLATE stream is self-contained.
- Good for text and structured data; mediocre for already-compressed media.
Newer algorithms (Brotli, Zstandard) compress better and are increasingly common on the web, but DEFLATE remains the universal fallback because every browser, OS, and tool supports it.
The patent-free origin story: Phil Katz designed DEFLATE in 1993 for PKZIP and explicitly published it royalty-free. That decision is the reason DEFLATE — not LZW (which Unisys held patents on until 2003) or arithmetic coding (which IBM patented) — became the universal default. The zlib library (Mark Adler & Jean-loup Gailly, 1995) provided a clean reference implementation under a permissive licence, which let every operating system, browser, and language runtime bundle the same code.
Why Brotli wins where DEFLATE loses: Brotli (Google, 2013) achieves 20-25% better compression than gzip on typical web text because it ships with a 120 kB static dictionary of common HTML, CSS, and JavaScript fragments — the decoder already “knows” phrases like <html lang="en"> without having to encode them in the stream. Zstandard (Facebook, 2016) trades a little compression for much faster decode speed and is now the default for the Linux kernel and many backup/archival workflows. All three coexist; Accept-Encoding: gzip, br, zstd negotiations let the server pick whichever the client supports. Related: lossless, ETag. Reference: RFC 1951 — DEFLATE Compressed Data Format Specification.
Why it matters: a measured example
Take a typical 100 kB minified jQuery 3.7 source file (102,310 bytes uncompressed). At default compression levels: gzip (DEFLATE level 6) produces about 36,200 bytes — a 64.6% reduction. Brotli at quality 11 reduces the same file to roughly 28,400 bytes (72.2% reduction). Zstd level 19 lands at about 30,100 bytes. The deltas look modest in isolation but compound: a typical e-commerce page ships ~250 kB of JS, CSS, and HTML, so switching from gzip to Brotli saves roughly 20 kB on the wire — which at typical 4G round-trip latency translates to 50-150 ms faster first contentful paint. Brotli is decode-asymmetric: encoding at quality 11 is slow (~50 ms for that 100 kB file) but decoding is nearly identical in speed to gzip, so the right pattern is to pre-compress static assets at build time and skip on-the-fly Brotli for dynamic responses.
Levels and the speed/ratio trade-off
DEFLATE’s nine compression levels (1-9) trade encode time for output size. Level 1 is roughly 5× faster than level 9 and produces output about 10-15% larger. Most web servers default to level 6, which sits at the inflection point of the curve. The pigz parallel implementation, by splitting input into independent blocks, makes level 9 affordable on multi-core machines for archival workloads. None of these settings affect decode speed — the decompressor reads whatever the encoder produced at constant throughput. Reference: RFC 1952 — GZIP file format specification.
Frequently asked questions
- What is Deflate?
- Deflate is a lossless compression algorithm combining LZ77 (back-references to earlier repeated strings) and Huffman coding (variable-length codes for frequent symbols). It is defined in RFC 1951 and is the compression engine inside ZIP archives, gzip, and PNG images.
- How is Deflate used in practice?
- When a browser requests a web page, the server typically responds with Content-Encoding: gzip — which is a Deflate-compressed stream with a gzip header. HTML, CSS, and JS files compress by 60–80%, reducing transfer time significantly on slow connections.
- What is the difference between Deflate, gzip, and zlib?
- Deflate is the core algorithm. zlib wraps Deflate with a small header and Adler-32 checksum (used inside PNG and HTTP zlib encoding). Gzip wraps Deflate with a larger header including filename and CRC-32 (used for files and HTTP gzip encoding). The compressed data is identical; only the wrapper differs.
- How does Deflate compare to Brotli and Zstandard?
- Brotli (used in modern HTTP compression) and Zstandard typically achieve 15–25% better compression than Deflate/gzip on web content, at comparable decompression speed. Deflate remains ubiquitous because it is baked into the ZIP, PNG, and PDF formats and has decades of hardware and software support.
Related
Published May 14, 2026 · Last reviewed May 31, 2026