Format Overview
The ZIP format provides:- Universal compatibility - Supported by virtually all platforms
- Multiple compression methods - Deflate, BZip2, LZMA, and more
- ZIP64 support - Files up to 16 exabytes
- Strong encryption - AES-256 and WinZip AES
- Split archives - Multi-volume support
- Self-extracting - Create executable archives
Format Structure
According tosource/CPP/7zip/Archive/Zip/ZipHeader.h, ZIP archives use the following structure:
Signature Constants
Fromsource/CPP/7zip/Archive/Zip/ZipHeader.h:13-23:
All multi-byte values in ZIP format use little-endian byte order.
Compression Methods
The ZIP format supports numerous compression methods (ZipHeader.h:37-68):
Standard Methods
- Store (0) - No compression
- Deflate (8) - Most common, good speed/ratio balance
- Deflate64 (9) - Enhanced Deflate
- BZip2 (12) - Better compression than Deflate
- LZMA (14) - Excellent compression ratio
Advanced Methods
- XZ (95) - LZMA2-based compression
- PPMd (98) - Context modeling compression
- Zstd (20, 93) - Modern fast compression
- WavPack (97) - Audio compression
- JPEG (96) - Image compression
Encryption Methods
- ZipCrypto - Legacy weak encryption (not recommended)
- WzAES (99) - AES encryption with authentication
Usage Examples
Create Standard ZIP Archive
Create ZIP with Maximum Compression
-tzip- ZIP format-mm=Deflate- Deflate compression method-mx=9- Maximum compression level
Create ZIP with LZMA Compression
ZIP archives with LZMA compression require 7-Zip or compatible software to extract. Standard ZIP utilities may not support this method.
Create Encrypted ZIP Archive
-mem=AES256- Use AES-256 encryption-p- Prompt for password
Create Split ZIP Archive
archive.zip, archive.z01, archive.z02, etc.
Create Self-Extracting Archive
ZIP64 Format
ZIP64 extensions allow archives to exceed original ZIP limitations:| Feature | Original ZIP | ZIP64 |
|---|---|---|
| Archive size | 4 GB | 16 EB |
| File size | 4 GB | 16 EB |
| Number of files | 65,535 | ~4 billion |
ZipHeader.h:31-33:
7-Zip automatically uses ZIP64 format when needed. You don’t need to specify it explicitly.
Version Requirements
Different ZIP features require minimum extraction versions (ZipHeader.h:72-82):
File Attributes
Host Operating Systems
ZIP format tracks the OS where the file was created (ZipHeader.h:155-180):
- FAT (0) - MS-DOS, Windows
- Unix (3) - Unix, Linux, macOS
- NTFS (11) - Windows NT
- VFAT (14) - Windows 95/NT
- OSX (19) - macOS
Extra Fields
ZIP supports various extra data fields (ZipHeader.h:86-102):
- Zip64 (0x01) - ZIP64 extended information
- NTFS (0x0A) - NTFS timestamps and attributes
- Unix Time (0x5455) - Unix timestamp
- Unicode Name (0x7075) - UTF-8 filename
- WzAES (0x9901) - AES encryption parameters
File Flags
FromZipHeader.h:136-142:
Advanced Features
Preserve Unix Permissions
-snl option stores symbolic links.
Exclude Files by Pattern
Update Existing Archive
List Archive Contents
Test Archive Integrity
Implementation Details
The ZIP handler is implemented in:Compression Level Comparison
Deflate Compression
| Level | Speed | Ratio | Use Case |
|---|---|---|---|
| -mx=1 | Fastest | ~40% | Quick backup |
| -mx=5 | Fast | ~50% | General use (default) |
| -mx=7 | Medium | ~55% | Better compression |
| -mx=9 | Slow | ~60% | Maximum Deflate |
Method Comparison (1 GB mixed files)
| Method | Time | Size | Compatibility |
|---|---|---|---|
| Store | 10s | 1000 MB | Universal |
| Deflate | 60s | 450 MB | Universal |
| Deflate64 | 75s | 430 MB | Good |
| BZip2 | 120s | 400 MB | Good |
| LZMA | 180s | 350 MB | Limited |
Performance varies significantly based on data type. Text files compress better than binary data or already-compressed formats.
Compatibility Notes
Universal Compatibility
For maximum compatibility across all platforms:Windows Compatibility
Windows Explorer can open ZIP files with:- Store (0)
- Deflate (8)
- No encryption or WinZip AES
macOS/Linux Compatibility
Most Unix tools support:- Store, Deflate, Deflate64
- BZip2 with proper libraries
Limitations
Best Practices
For Sharing
Use Deflate compression with
-mx=5 to -mx=7For Security
Use AES-256 encryption:
-mem=AES256 -pFor Size
Use LZMA method if recipients have 7-Zip
For Speed
Use Deflate with
-mx=1 for fast compression