What Is 7-Zip and the 7z Format?
7-Zip is an open-source file archiver created by Igor Pavlov in 1999, released under GNU LGPL. The .7z format is 7-Zip's native format, designed for maximum compression ratios.
The core of 7z is the LZMA algorithm (Lempel-Ziv-Markov chain), with its improved variant LZMA2 that leverages multiple CPU cores for parallel compression.
7z vs ZIP vs RAR vs tar.gz
| Feature | ZIP | RAR | tar.gz | 7z |
|---|---|---|---|---|
| Algorithm | DEFLATE | RAR/LZMA | gzip | LZMA/LZMA2 |
| Compression ratio | Low-Medium | Good | Medium | Excellent |
| Encryption | AES-256 | AES-256 | None | AES-256 |
| Native on Windows | ✅ | ❌ | ❌ | ❌ |
| Native on macOS | ✅ | ❌ | ✅ | ❌ |
| Open source | ✅ | ❌ | ✅ | ✅ |
Real Compression Rates
Compressing a 1 GB documents folder:
| Format | Result size | Time |
|---|---|---|
| ZIP | ~280 MB | 10 s |
| tar.gz | ~240 MB | 15 s |
| 7z (normal) | ~220 MB | 18 s |
| 7z (ultra) | ~200 MB | 120 s |
With source code or text files, 7z's advantage is even greater (40-60% better than ZIP).
Create 7z Archives (Command Line)
# Compress a folder to 7z
7z a archive.7z folder/
# Maximum compression
7z a -mx=9 archive.7z folder/
# With AES-256 encryption (encrypt headers too)
7z a -p"secure_password" -mhe=on archive.7z folder/
# Split into 1 GB volumes
7z a -v1g archive.7z folder/
# Exclude specific files
7z a archive.7z folder/ -xr!*.log -xr!tmp/
Extract 7z Archives
# Extract to current directory
7z x archive.7z
# Extract to specific directory
7z x archive.7z -o/path/destination/
# List contents without extracting
7z l archive.7z
# Verify integrity
7z t archive.7z
Automation with Python
import subprocess
def compress_7z(source: str, output: str, password: str = None, level: int = 5):
cmd = ['7z', 'a', f'-mx={level}', output, source]
if password:
cmd.extend([f'-p{password}', '-mhe=on'])
result = subprocess.run(cmd, capture_output=True, text=True)
return result.returncode == 0
def extract_7z(archive: str, destination: str, password: str = None):
cmd = ['7z', 'x', archive, f'-o{destination}']
if password:
cmd.append(f'-p{password}')
result = subprocess.run(cmd, capture_output=True, text=True)
return result.returncode == 0
Formats Supported by 7-Zip
7-Zip can extract: 7z, ZIP, RAR (including RAR5), TAR, GZ, BZ2, XZ, ISO, LZMA, CAB, MSI, ARJ, Z, LZH, CHM, DMG, WIM, NSIS, RPM, DEB, and more.
When to Use 7z
Use it when:
- Maximum compression is needed (backups, large software distribution).
- AES-256 encryption with encrypted headers is required.
- Recipients can install 7-Zip.
Prefer ZIP when:
- Recipients use Windows/macOS without additional software.
- Maximum universal compatibility is needed.
Conclusion
7-Zip and the 7z format offer the best freely available compression ratio, with high-security AES-256 encryption. For personal backups and technical distribution, 7z is the optimal choice.
Related conversions
Archive format conversions used most often: