GZip / Deflate

Compress strings using GZip/Deflate or decompress encoded Base64 strings.

GZip / Deflate Utility
Output

About GZip & Deflate Compression Algorithms

GZip (GNU zip) and Deflate are ubiquitous lossless data compression standards designed to reduce file sizes and network bandwidth consumption. Standardized in RFC 1951 (Deflate) and RFC 1952 (GZip), these algorithms form the backbone of HTTP content encoding (Content-Encoding: gzip), software package distribution, and modern data transmission pipelines.

The Mechanics of Deflate: LZ77 & Huffman Coding

Deflate achieves high compression ratios by chaining two distinct algorithmic phases in memory:

  1. LZ77 Sliding Window Compression: The algorithm scans the input stream with a sliding dictionary window (typically 32KB). When it detects recurring sequences of bytes, it replaces the duplicate string with a compact length-distance pointer pair (distance, length) referencing the previous occurrence.
  2. Huffman Variable-Length Prefix Coding: The output from LZ77 is analyzed for character frequency. Frequently occurring symbols and pointers are assigned shorter bit sequences, while rare characters receive longer bit sequences, minimizing total bit consumption.
  3. GZip Wrapper: The GZip format encapsulates Deflate payload data with a 10-byte header (including magic numbers 0x1f 0x8b, compression method, timestamp, and OS flags) and an 8-byte trailer containing a CRC-32 checksum and original uncompressed length.

Primary Applications in Web Engineering

  • HTTP Web Asset Optimization: Compressing HTML, CSS, JavaScript, and JSON payloads before sending them over the wire to dramatically accelerate First Contentful Paint (FCP) and Google Core Web Vitals.
  • Database Log & Backup Storage: Reducing the disk footprint of database dumps, access logs, and historical archives by up to 70%–90%.
  • Payload Inspection & Debugging: Decoding raw binary compressed response bodies from HTTP proxies (like Charles or Fiddler) into readable text.

Frequently Asked Questions (FAQ)

What is the difference between GZip, Zlib, and Deflate?

Deflate is the raw compression algorithm. Zlib is Deflate wrapped with an RFC 1950 header and Adler-32 checksum. GZip is Deflate wrapped with an RFC 1952 header, metadata, and CRC-32 checksum.

Why do some small strings get larger after GZip compression?

Small strings lack repeated patterns for LZ77 to optimize. Adding the 18-byte GZip header, Huffman tree tables, and CRC-32 checksum increases the total byte length beyond the tiny original string.

Is my data compressed securely?

Yes. All compression and decompression operations execute entirely within your browser using the high-performance fflate WebAssembly/JS library. Your raw inputs are never sent to external servers.