Format Overview
The 7z format offers several key advantages:- High compression ratio - Typically 30-70% better than ZIP
- Open architecture - Supports any compression method
- Strong AES-256 encryption - Encrypts both file names and data
- Large file support - Up to 16 exabytes (2^64 bytes)
- Solid compression - Treats multiple files as continuous stream
- Unicode file names - Full UTF-16 support
Format Structure
According to the official format specification (source/DOC/7zFormat.txt), a 7z archive consists of:
Signature Header
Every 7z file begins with a signature header:37 7A BC AF 27 1C in hexadecimal.
The current format version is 0.4 (Major=0, Minor=4). All 7z archives created by 7-Zip 18.06 and later use this version.
Compression Methods
The 7z format supports multiple compression codecs, defined insource/CPP/7zip/Archive/7z/7zHeader.h:100-128:
Primary Compression
- LZMA2 (0x21) - Default, best compression ratio
- LZMA (0x30101) - Original algorithm
- PPMd (0x30401) - Good for text files
- Deflate (0x40108) - Compatible with ZIP
- BZip2 (0x40202) - Alternative compression
Filters (BCJ)
Filters improve compression for executable files:- BCJ (0x3030103) - x86 executables
- BCJ2 (0x303011B) - x86 with better ratio
- ARM (0x3030501) - ARM executables
- ARM64 (0xa) - ARM64 executables
- PPC (0x3030205) - PowerPC executables
- IA64 (0x3030401) - Itanium executables
- SPARC (0x3030805) - SPARC executables
Encryption
- AES-256 (0x6F10701) - Strong encryption with SHA-256 key derivation
Usage Examples
Create Archive with Maximum Compression
-t7z- Use 7z format-m0=lzma2- Use LZMA2 compression-mx=9- Maximum compression level-mfb=64- 64 word size for fast bytes-md=32m- 32 MB dictionary size-ms=on- Enable solid mode
Create Encrypted Archive
-p- Prompt for password-mhe=on- Encrypt headers (file names)
Create Multi-Volume Archive
archive.7z.001, archive.7z.002, etc., each 100 MB.
Solid vs Non-Solid Archives
Solid archive (better compression):Solid compression treats all files as a continuous data stream, achieving better compression but requiring extraction of all prior files to access a specific file.
Advanced Features
Compression Method Chaining
The 7z format supports multiple compression methods in a chain:Self-Extracting Archives
Archive Update
The 7z format supports efficient updates:File Properties
The 7z format stores comprehensive file metadata (7zFormat.txt:80-89):
- Names (0x11) - UTF-16 file names
- CTime (0x12) - Creation time
- ATime (0x13) - Last access time
- MTime (0x14) - Modification time
- WinAttributes (0x15) - Windows file attributes
- Comment (0x16) - File comments
Format Limitations
While the 7z specification supports files up to 16 exabytes, practical limitations include:
- Available RAM for dictionary during compression/decompression
- File system limitations (FAT32, NTFS, etc.)
- 32-bit vs 64-bit executable limitations
Implementation Details
The 7z format handler is implemented in:Header Structure
Fromsource/CPP/7zip/Archive/7z/7zHeader.h:11-37:
Performance Considerations
Compression Level Impact
| Level | Speed | Ratio | Dictionary | Description |
|---|---|---|---|---|
| -mx=1 | Fastest | Lowest | 64 KB | Fast compression |
| -mx=5 | Fast | Normal | 16 MB | Default |
| -mx=7 | Medium | Good | 32 MB | High compression |
| -mx=9 | Slow | Best | 64 MB | Ultra compression |
Memory Requirements
Memory usage during compression (LZMA2):Comparison with Other Formats
7z vs ZIP:- Compression: 7z typically 30-70% better
- Speed: ZIP faster for creation and extraction
- Compatibility: ZIP more widely supported
- Features: 7z has solid compression, better encryption
- Compression: Similar ratio, depends on content
- Open source: 7z is open source, RAR is proprietary
- Speed: RAR slightly faster for creation
- Recovery: RAR has better recovery records
Best Practices
For Distribution
Use
-mx=5 or -mx=7 for good compression with reasonable speedFor Archival
Use
-mx=9 -ms=on for maximum compressionFor Security
Use
-p -mhe=on to encrypt both data and file namesFor Updates
Use non-solid archives (
-ms=off) for better update performance