Guide
ZIP vs 7z vs tar.gz vs zst: which archive format to use
Compression ratio, speed, encryption and compatibility of the common archive formats, and which one to pick for downloads, backups and data.
Use ZIP when the recipient might be on any operating system, tar.gz (or tar.zst) for software and anything Unix, and 7z when the smallest file or strong encryption of file names matters. Every claim below links to a sample you can test.
At a glance
| Format | Opens natively on | Compression | Encryption | Notes |
|---|---|---|---|---|
| ZIP | Windows, macOS, Linux | Deflate (per file) | ZipCrypto (weak) or AES | Random access to single files |
| 7z | Needs 7-Zip or similar | LZMA2 (very high) | AES-256, including names | Solid archives compress best |
| tar.gz | macOS, Linux | gzip over the whole archive | None built in | Keeps Unix permissions |
| tar.xz | macOS, Linux | LZMA2 | None built in | Smaller than gzip, slower |
| tar.zst | Linux, recent macOS | Zstandard | None built in | xz-like ratio, much faster |
Compression
ZIP compresses each file separately, which allows extracting one file without reading the rest but misses redundancy between files. tar.gz, tar.xz and solid 7z compress the whole stream, so similar files shrink together. Compare the same folder as ZIP, tar.gz, tar.xz, tar.zst and 7z.
Random data does not compress at all, which is why our large test files are random: the archive is the same size as its contents.
Encryption
Classic ZIP encryption (ZipCrypto) is weak and leaves file names visible — try the password-protected ZIP. 7z uses AES-256 and can encrypt the file list too (sample). tar has no encryption; pipe it through GPG or age instead.
Commands
# ZIP
zip -r archive.zip folder/
unzip archive.zip
# tar.gz and tar.zst
tar -czf archive.tar.gz folder/
tar --zstd -cf archive.tar.zst folder/
tar -xf archive.tar.zst
# 7z with an encrypted file list
7z a -p -mhe=on archive.7z folder/Before you extract user uploads
Archives are a common attack vector: path traversal, symlinks and compression bombs. Read extracting user-uploaded archives safely and test with the archive extraction use case.