SpeedDrain
Deflate · Gzip Lv6 · Brotli Modeling · Shannon Entropy

Gzip & Brotli Compression Calculator

Benchmark compression ratios for web code, stylesheets, and JSON APIs. Measure byte-level savings, examine Shannon entropy, and simulate real-world mobile transfer speeds.

Sample Assets:
783 Bytes
Uncompressed Size
783 B
Original wire payload
Gzip (Deflate Lv6)
422 B
-46.1% Reduction
Brotli (Estimated)
346 B
-55.8% Reduction
Shannon Entropy
4.75 b/B
Max 8.0 (Random)

Relative Bandwidth Footprint

Uncompressed Original783 B (100%)
Gzip Compressed422 B (53.9%)
Brotli Compressed346 B (44.2%)

Network Transfer Time Simulation

Network ProfileRaw Transfer TimeGzip Transfer TimeTime Saved
Slow 3G (400 Kbps)15.7 ms8.4 ms-7.2 ms
Fast 3G (1.6 Mbps)3.9 ms2.1 ms-1.8 ms
4G LTE (15 Mbps)0.4 ms0.2 ms-0.2 ms
5G / Fiber (100 Mbps)0.1 ms0.0 ms-0.0 ms

Lossless Web Compression: LZ77, Huffman Coding, Brotli & Shannon Entropy

How the Deflate (Gzip) Algorithm Compresses

Standard Gzip (RFC 1952) is built upon the DEFLATE algorithm, combining two distinct techniques:

  • LZ77 Sliding Window: Replaces repeated substrings with backward references consisting of a distance and length pointer (e.g. "the same word as 120 bytes ago for 14 characters").
  • Huffman Coding: Replaces fixed 8-bit byte representations with variable-bit prefix codes, assigning fewer bits to high-frequency characters (like e or space).
  • Overhead on Tiny Files: For strings smaller than ~150 bytes, Gzip can actuallyincrease file size due to the 10-byte header, 8-byte footer, and Huffman tree definitions.

Brotli vs. Gzip in Modern Browsers

Developed by Google and supported by all evergreen browsers via the br content-encoding header:

  • Predefined Static Dictionary: Brotli embeds a 120 KB static dictionary containing over 13,000 common words, HTML tags (<html>, <div>), and common JavaScript phrases.
  • 15% - 25% Smaller Bundles: Because common web patterns are already recognized in the static dictionary, Brotli compresses web assets substantially more effectively than Gzip.
  • Woff2 Webfonts: The modern WOFF2 font format internally utilizes Brotli compression.

Understanding Shannon Entropy

Formulated by Claude Shannon in 1948, information entropy measures the average amount of information produced by each byte: $H = -\sum p_i \log_2(p_i)$. A pure repetitive string has near-zero entropy (highly compressible), while encrypted or already-compressed data approaches 8.0 bits per byte, representing mathematical randomness where no lossless compression can reduce size further.