Skip to main content
GZIP is a widely-used compression format based on the DEFLATE algorithm, commonly used for single-file compression and TAR archives.

Format Overview

GZIP provides:
  • Universal support - Available on all Unix/Linux systems
  • Fast compression - Good speed-to-ratio balance
  • Deflate algorithm - LZ77 + Huffman coding
  • Single file compression - Compresses one file or stream
  • CRC32 integrity - Built-in error detection
  • Metadata support - Filename, timestamp, OS information
GZIP is designed for single-file compression. For multiple files, use TAR+GZIP (.tar.gz) or switch to 7z/ZIP formats.

Format Structure

From source/CPP/7zip/Archive/GzHandler.cpp:38-86, GZIP file structure:

Header Format

Header Flags

From GzHandler.cpp:45-53:

Extra Flags

Indicates compression level used:
GZIP stores file size as 32-bit value, limiting uncompressed files to 4 GB. For larger files, use XZ or 7z formats.

Supported Operating Systems

GZIP tracks the OS where file was compressed (GzHandler.cpp:62-110):

Usage Examples

Compress Single File

Creates compressed file, removes original by default with some tools.

Compress with Maximum Compression

Compress with Fast Speed

Decompress File

Extracts to file.txt.

Create TAR.GZ Archive

Or using system tar:

Compress with Filename Stored

Stores “original.txt” as the original filename in the GZIP header.

Compression Levels

Performance Comparison (100 MB text file)

Deflate algorithm provides diminishing returns at higher compression levels. Level 6-7 often provides the best balance.

Advanced Usage

Compress Standard Input

Decompress to Standard Output

Multiple Files (TAR+GZIP)

Test Integrity

Verifies CRC32 checksum and structure.

View File Info

Shows:
  • Original filename
  • Modification time
  • Uncompressed size
  • CRC32 value
  • Host OS

Implementation Details

GZIP handler in 7-Zip:
Key components:
Uses compression codecs from:

Comparison with Other Formats

GZIP vs BZIP2

GZIP vs XZ

GZIP vs 7z

Best Practices

For Web Servers

Use -mx=6 for optimal speed/size balance on HTTP compression

For Log Files

Use -mx=9 for maximum compression of text logs

For Backups

Combine with TAR for multiple files: .tar.gz

For Fast Compression

Use -mx=1 or -mx=3 for quick compression

Common Use Cases

Web Content Compression

Log File Rotation

Database Backup

Source Code Archive

Limitations

GZIP format limitations:
  • Single file only (use TAR for multiple files)
  • 4 GB uncompressed file size limit
  • No encryption support
  • No error recovery or redundancy
  • Lower compression ratio than BZIP2/XZ/LZMA

Compatibility

Universal Support

GZIP is supported by:
  • All Linux distributions (gunzip, gzip command)
  • macOS (built-in gzip)
  • Windows (7-Zip, WinZip, various tools)
  • Web browsers (HTTP compression)
  • Programming languages (zlib library)

HTTP Compression

GZIP is the most common HTTP compression:
Supported by all modern browsers.

Performance Tips

  1. Use appropriate compression level - Level 6 is usually optimal
  2. Pre-filter data - Remove redundant data before compression
  3. Use TAR for multiple files - Don’t compress files individually
  4. Consider alternatives - Use XZ for better ratio, BZIP2 for medium ratio
  5. Parallel compression - Use pigz for multi-core compression

See Also