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
Fromsource/CPP/7zip/Archive/GzHandler.cpp:38-86, GZIP file structure:
Header Format
Header Flags
FromGzHandler.cpp:45-53:
Extra Flags
Indicates compression level used:Footer Format
Supported Operating Systems
GZIP tracks the OS where file was compressed (GzHandler.cpp:62-110):
Usage Examples
Compress Single File
Compress with Maximum Compression
Compress with Fast Speed
Decompress File
file.txt.
Create TAR.GZ Archive
Compress with Filename Stored
Compression Levels
Performance Comparison (100 MB text file)
| Level | Time | Size | Ratio | Speed |
|---|---|---|---|---|
| -mx=1 | 2s | 35 MB | 35% | Fastest |
| -mx=3 | 3s | 32 MB | 32% | Fast |
| -mx=5 | 5s | 30 MB | 30% | Normal (default) |
| -mx=7 | 8s | 29 MB | 29% | High |
| -mx=9 | 12s | 28 MB | 28% | Maximum |
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
View File Info
- Original filename
- Modification time
- Uncompressed size
- CRC32 value
- Host OS
Implementation Details
GZIP handler in 7-Zip:Comparison with Other Formats
GZIP vs BZIP2
| Feature | GZIP | BZIP2 |
|---|---|---|
| Algorithm | Deflate (LZ77+Huffman) | Burrows-Wheeler |
| Speed | Fast | Slower |
| Ratio | Good | Better |
| File size limit | 4 GB | Unlimited |
| Compression time | 1x | ~3x |
| Decompression | 1x | ~2x |
GZIP vs XZ
| Feature | GZIP | XZ |
|---|---|---|
| Algorithm | Deflate | LZMA2 |
| Speed | Fast | Slow |
| Ratio | Good | Excellent |
| File size limit | 4 GB | 16 EB |
| Memory usage | Low | High |
| Decompression | Fast | Medium |
GZIP vs 7z
| Feature | GZIP | 7z |
|---|---|---|
| Multiple files | No (needs TAR) | Yes |
| Solid compression | No | Yes |
| Encryption | No | Yes (AES-256) |
| Compression ratio | Good | Excellent |
| Compatibility | Universal | Requires 7-Zip |
Best Practices
For Web Servers
Use
-mx=6 for optimal speed/size balance on HTTP compressionFor Log Files
Use
-mx=9 for maximum compression of text logsFor Backups
Combine with TAR for multiple files:
.tar.gzFor Fast Compression
Use
-mx=1 or -mx=3 for quick compressionCommon Use Cases
Web Content Compression
Log File Rotation
Database Backup
Source Code Archive
Limitations
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:Performance Tips
- Use appropriate compression level - Level 6 is usually optimal
- Pre-filter data - Remove redundant data before compression
- Use TAR for multiple files - Don’t compress files individually
- Consider alternatives - Use XZ for better ratio, BZIP2 for medium ratio
- Parallel compression - Use pigz for multi-core compression