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

FormatOpens natively onCompressionEncryptionNotes
ZIPWindows, macOS, LinuxDeflate (per file)ZipCrypto (weak) or AESRandom access to single files
7zNeeds 7-Zip or similarLZMA2 (very high)AES-256, including namesSolid archives compress best
tar.gzmacOS, Linuxgzip over the whole archiveNone built inKeeps Unix permissions
tar.xzmacOS, LinuxLZMA2None built inSmaller than gzip, slower
tar.zstLinux, recent macOSZstandardNone built inxz-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

Shell
# 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.

Sample files for this guide