zstd
37c3317fd058; modified for Encode Wiki · CC BY-SA 4.0Zstandard (zstd) is Yann Collet’s compressor, developed at Facebook (now Meta) and specified in RFC 8878. It compresses and decompresses faster than gzip at a better ratio, its high levels approach xz, and decompression speed barely depends on the level. That makes it the sensible default for archives, backups, logs, container images and intermediate files. Arch Linux packages are zstd-compressed, and the Linux kernel, btrfs, SquashFS and OpenZFS all support it.
Common commands
Section titled “Common commands”zstd file # file.zst, level 3, source keptzstd -19 -T0 file # slower, much smaller, all coreszstd --ultra -22 -T0 file # maximum; needs lots of memoryzstd -d file.zst # decompresszstd -dc file.zst | less # to stdoutzstd -t file.zst # test integrityUnlike gzip and xz, zstd keeps the input file by default (--rm deletes it). Output has a .zst extension.
| Option | Effect |
|---|---|
-1 … -19 | Compression level; default 3. -19 is about the useful limit |
--ultra -20…-22 | Even slower and memory-hungry, with small gains; the decoder also needs more memory |
--fast=N | Negative levels, faster than -1 with worse ratios |
-T0 | Use all cores (default is 1); also speeds up higher levels a lot |
--long[=27] | Long-distance matching with a 128 MiB window; helps on big files with distant repeats (VM images, tarballs of similar trees) |
--adapt | Change the level on the fly to match how fast the output is being consumed (good for piping over a network) |
-D dict | Use a trained dictionary; zstd --train files… builds one. Big wins on many small similar files |
Levels 3–9 are the sweet spot for logs, backups and anything compressed repeatedly. Use 19 for things compressed once and read many times.
Larger windows need matching decompression settings
Section titled “Larger windows need matching decompression settings”With --long=N for N above 27, the decompressor must be given --long=N too (or --memory=…), otherwise it refuses the file to protect itself from huge allocations. Archives made with the default window decompress anywhere.
Archives and other formats
Section titled “Archives and other formats”zstd compresses one stream, not a directory, so combine it with tar:
tar --zstd -cf backup.tar.zst dir/tar -I 'zstd -19 -T0' -cf backup.tar.zst dir/tar -xf backup.tar.zstThe zstd binary can also read and write gzip, xz and lzma streams (--format=gzip). 7-Zip can unpack .zst files since 24.01 but does not create them.
zstd is a registered HTTP content coding. Chrome and Edge 123, Firefox 126 and Safari 26.3 (iOS, or macOS 26.3 and later) advertise it in Accept-Encoding; see Can I use. HTTP zstd limits the window to 8 MiB (RFC 9659), so do not serve files compressed with --long or --ultra levels (20–22) as Content-Encoding: zstd. Level 19 and below stay within the limit. Brotli (brotli) is the established alternative for static web assets and has wider browser support.