zstd(1) – zstd, zstdmt, unzstd, zstdcat - Compress or decompress .zst files

SYNOPSIS

zstd [OPTIONS] [-|INPUT-FILE] [-o OUTPUT-FILE]

zstdmt is equivalent to zstd -T0

unzstd is equivalent to zstd -d

zstdcat is equivalent to zstd -dcf

DESCRIPTION

zstd is a fast lossless compression algorithm and data compression tool, with command line syntax similar to gzip (1) and xz (1). It is based on the LZ77 family, with further FSE & huff0 entropy stages. zstd offers highly configurable compression speed, with fast modes at > 200 MB/s per core, and strong modes nearing lzma compression ratios. It also features a very fast decoder, with speeds > 500 MB/s per core.

zstd command line syntax is generally similar to gzip, but features the following differences :

zstd compresses or decompresses each file according to the selected operation mode. If no files are given or file is -, zstd reads from standard input and writes the processed data to standard output. zstd will refuse to write compressed data to standard output if it is a terminal : it will display an error message and skip the file. Similarly, zstd will refuse to read compressed data from standard input if it is a terminal.

Unless --stdout or -o is specified, files are written to a new file whose name is derived from the source file name:

Concatenation with .zst files

It is possible to concatenate .zst files as is. zstd will decompress such files as if they were a single .zst file.

OPTIONS

Integer suffixes and special values

In most places where an integer argument is expected, an optional suffix is supported to easily indicate large integers. There must be no space between the integer and the suffix.

Operation mode

If multiple operation mode options are given, the last one takes effect.

Operation modifiers

Restricted usage of Environment Variables

Using environment variables to set parameters has security implications. Therefore, this avenue is intentionally restricted. Only ZSTD_CLEVEL is supported currently, for setting compression level. ZSTD_CLEVEL can be used to set the level between 1 and 19 (the “normal” range). If the value of ZSTD_CLEVEL is not a valid integer, it will be ignored with a warning message. ZSTD_CLEVEL just replaces the default compression level (3). It can be overridden by corresponding command line arguments.

DICTIONARY BUILDER

zstd offers dictionary compression, which greatly improves efficiency on small files and messages. It’s possible to train zstd with a set of samples, the result of which is saved into a file called a dictionary. Then during compression and decompression, reference the same dictionary, using command -D dictionaryFileName. Compression of small files similar to the sample set will be greatly improved.

BENCHMARK

Output Format: CompressionLevel#Filename : IntputSize -> OutputSize (CompressionRatio), CompressionSpeed, DecompressionSpeed

Methodology: For both compression and decompression speed, the entire input is compressed/decompressed in-memory to measure speed. A run lasts at least 1 sec, so when files are small, they are compressed/decompressed several times per run, in order to improve measurement accuracy.

ADVANCED COMPRESSION OPTIONS

–zstd[=options]:

zstd provides 22 predefined compression levels. The selected or default predefined compression level can be changed with advanced compression options. The options are provided as a comma-separated list. You may specify only the options you want to change and the rest will be taken from the selected or default compression level. The list of available options:

Example

The following parameters sets advanced compression options to something similar to predefined level 19 for files bigger than 256 KB:

--zstd=wlog=23,clog=23,hlog=22,slog=6,mml=3,tlen=48,strat=6

-B#:

Select the size of each compression job. This parameter is available only when multi-threading is enabled. Default value is 4 * windowSize, which means it varies depending on compression level. -B# makes it possible to select a custom value. Note that job size must respect a minimum value which is enforced transparently. This minimum is either 1 MB, or overlapSize, whichever is largest.

BUGS

Report bugs at: https://github.com/facebook/zstd/issues

AUTHOR

Yann Collet