What is Gzip?

Gzip is a file compression format and software application that uses the DEFLATE algorithm to reduce file sizes, widely used for compressing web content and reducing bandwidth consumption in HTTP transfers.

Quick Facts

Full NameGNU Zip Compression
Created2026-02-01
SpecificationOfficial Specification

How Gzip Works

Gzip combines the LZ77 algorithm and Huffman coding in its DEFLATE compression method to achieve efficient lossless data compression. Originally developed by Jean-loup Gailly and Mark Adler as a free replacement for the Unix compress utility, Gzip has become the de facto standard for HTTP compression. Web servers can compress responses with Gzip before sending them to browsers, significantly reducing transfer times. The format adds a small header containing metadata like original filename and modification time. Typical compression ratios for text-based content range from 70-90%, making it essential for web performance optimization.

Key Characteristics

  • Uses DEFLATE algorithm (LZ77 + Huffman coding)
  • Lossless compression preserves original data exactly
  • File extension: .gz
  • Magic number: 1f 8b (hex)
  • Compression levels 1-9 (speed vs ratio tradeoff)
  • Single file compression (use tar for archives)
  • HTTP Content-Encoding: gzip header

Common Use Cases

  1. HTTP response compression
  2. Log file compression
  3. Backup and archival storage
  4. Software distribution packages
  5. Database dump compression

Example

gzip -9 file.txt