What Is Zstandard?
Zstandard (often abbreviated as zstd) is a lossless data compression algorithm developed at Facebook (now Meta) by Yann Collet. It was released in 2016 and open-sourced under a BSD licence. The algorithm is designed to provide compression ratios comparable to zlib/Deflate while being significantly faster — and it can scale to much higher compression levels when speed is less important.
Files compressed with Zstandard typically use the .zst extension. In practice, you will most often see it as .tar.zst for compressed archives in development and server environments.
Why Zstandard Exists
Gzip (using Deflate) has been the default compression algorithm for decades. It is everywhere — HTTP compression, archive files, package managers, log files. But Deflate was designed in the early 1990s and its performance reflects that era.
Zstandard addresses two limitations:
- Speed: At comparable compression ratios, zstd compresses 3–5× faster than gzip and decompresses 2–3× faster.
- Scalability: zstd supports compression levels from 1 (very fast, moderate ratio) to 22 (slower, excellent ratio), giving you much finer control over the speed/ratio trade-off than gzip's limited 1–9 range.
Performance Benchmarks
Typical benchmarks on mixed data (Silesia corpus, enwik datasets):
| Algorithm | Compression Ratio | Compress Speed | Decompress Speed |
|---|---|---|---|
| gzip -6 | 3.1× | ~35 MB/s | ~280 MB/s |
| zstd -3 (default) | 3.1× | ~350 MB/s | ~1,200 MB/s |
| zstd -19 | 3.6× | ~8 MB/s | ~1,200 MB/s |
| bzip2 | 3.4× | ~12 MB/s | ~35 MB/s |
| xz (LZMA2) | 3.7× | ~6 MB/s | ~150 MB/s |
The key insight: zstd at its default setting matches gzip's compression ratio while compressing 10× faster and decompressing 4× faster. At higher settings, it approaches LZMA2's ratio while maintaining much faster decompression.
Where Zstandard Is Used
- Linux kernel: Supported as a filesystem compression option (Btrfs) and for kernel image compression
- Package managers: Arch Linux (pacman), Fedora (rpm), and others use zstd for package compression
- Databases: Used in MySQL, PostgreSQL (for WAL compression), and RocksDB
- HTTP compression: Supported as Content-Encoding in modern servers, though browser support is limited to Chrome (behind a flag) — Brotli remains the preferred HTTP compression
- Facebook/Meta: Compresses hundreds of petabytes of data daily using zstd
- Game distribution: Several game launchers use zstd for faster asset delivery
How to Use Zstandard
Command-Line
# Compress a file
zstd myfile.txt # produces myfile.txt.zst
# Decompress
zstd -d myfile.txt.zst # restores myfile.txt
# Compress at a higher level (1-22)
zstd -19 myfile.txt # better ratio, slower
# Create a tar.zst archive
tar --zstd -cf archive.tar.zst my-folder/
# Extract a tar.zst archive
tar --zstd -xf archive.tar.zst Installing zstd
- Windows: Available via chocolatey (
choco install zstandard) or download from GitHub releases - macOS:
brew install zstd - Linux: Pre-installed on most modern distributions, or install via your package manager
Dictionary Compression
One of Zstandard's distinctive features is built-in dictionary compression. By training a dictionary on sample data, zstd can achieve dramatically better compression on small, similar files — think JSON API responses, log entries, or small database records.
# Train a dictionary from sample files
zstd --train samples/* -o my.dict
# Compress using the dictionary
zstd -D my.dict smallfile.json With dictionary mode, zstd can compress small files (1–10 KB) far more effectively than any general-purpose algorithm.
When to Use Zstandard
Good fits:
- Log file compression where speed matters
- Database backups and snapshots
- CI/CD artefact caching
- Any scenario where you would use gzip but want better performance
- Filesystem-level compression (Btrfs, ZFS)
Less suitable:
- HTTP content compression for web pages (Brotli has better browser support)
- Distributing archives to end users who may not have zstd installed (use ZIP)
- Maximum compression ratio with no speed constraints (LZMA2/xz edges ahead at extreme settings)
Frequently Asked Questions
Is Zstandard better than gzip?
For most server-side use cases, yes. It is faster to compress, faster to decompress, and achieves the same or better ratios. The main reason to keep using gzip is when you need compatibility with systems that do not yet support zstd.
Can I use .zst files on Windows?
Yes, though you need a tool that supports it. 7-Zip 23.01+ can extract .zst files, and the zstd command-line tool runs on Windows.
How does zstd compare to Brotli?
Brotli and zstd serve different primary use cases. Brotli is optimised for HTTP compression with a built-in static dictionary for web content. Zstandard is a general-purpose algorithm that is faster at compression and decompression. For web pages, Brotli is preferred; for everything else, zstd usually wins.