Introduction
Zstandard, or zstd, is a compression method made by Yann Collet at Facebook and
released in 2016 with the zstd tool. It
compresses about as well as gzip at its fast
settings and nearly as well as xz at its slow ones,
while decompressing much faster than either. It is now common for software packages,
such as Arch Linux’s .pkg.tar.zst, for file system and database compression,
and for web traffic. The format is RFC 8878.
Zstandard can also use a dictionary trained on sample data, which helps
a great deal when compressing many small, similar files or messages. Over HTTP the
dcz content coding (RFC 9842) uses a raw dictionary the client already holds,
named by its SHA-256 in a 40-byte skippable frame in front of the stream: that is a format
of its own, .DCZ, Dictionary-Compressed Zstandard.
Structure
A .zst file is one or more frames one after another.
Numbers are little-endian.
0Magic28 B5 2F FD4 bytes4Frame header a descriptor byte, then optional window size, dictionary ID and content size2 to 14 bytes…Blocks each a 3-byte header (last-block flag, type, size) and its datarepeated…Checksum low 32 bits of the XXH64 hash of the content, if the descriptor asks for it0 or 4 bytes
A block is raw (stored as it is), RLE (one byte repeated) or compressed. A compressed
block holds literals coded with Huffman coding and sequences of matches coded with
finite state entropy. A skippable frame, with a magic from
50 2A 4D 18 to 5F 2A 4D 18, carries other data that
decompressors ignore. The frames and blocks
and compressed blocks pages give
every field and code.
Media type and security
RFC 8878 (section 7) registers application/zstd (binary, file extension
zst, magic number FD2FB528 little-endian, author Murray S.
Kucherawy, change controller IETF), the HTTP content coding zstd and the
structured syntax suffix +zstd. It reserves dictionary IDs up to 32,767 and
from 231 up for dictionaries registered with IANA, but the RFC says no
dictionaries are published for public use yet and does not ask IANA to create a
registry (section 7.4). Content sent with the media type should
not use a dictionary unless the parties arrange one privately (section 6). The
security notes (section 8) are: never compress a secret together with data from a third
party (the CRIME attack); a decoder must bounds-check everything, in particular
Number_of_Sequences values that would read into the block header and a
Frame_Content_Size smaller than the real content, and must limit memory
for frames that ask for unreasonable windows; third-party dictionaries can exhaust
resources; and a skippable frame can carry a watermark that tracks a payload.
In the explorer
Drop a .zst, .zstd or .tzst file on this site,
or a dictionary made by zstd --train. The decompressed data opens as a file
of its own, in its own viewer: .tar.zst and .tzst as a tar
archive, .json.zst as JSON. The structure tree shows every frame (magic,
descriptor, window, dictionary ID, content size), every block (header, type, size) and
for compressed blocks the literals section (type, sizes, Huffman tree description and
streams) and the sequences section (count, modes, FSE tables, bitstream). It checks each
frame’s content checksum against the decoded data, lists skippable frames with their
magic nibble and size, and opens a dictionary into its ID, entropy tables, repeat
offsets and content.
Not described
Checked against RFC 8878 in the November 2026 re-check and again when the viewer was written; these parts are not on the pages or not in the viewer yet.
Known, not yet covered
- Reference: the RFC’s Appendix A, the full FSE decoding tables (symbol, number of bits, baseline per state) for the three default distributions. The construction rules are given, the finished tables are not listed. (The explorer builds them by those rules and decodes real files with them.)
- Reference: the seekable format and other uses of skippable frames, which the RFC does not define.
- Viewer: (a .dcz file is the exception: it is opened with its dictionary when the dictionary is dropped with it, and found by its SHA-256.) For every other file, a frame that names a dictionary needs that dictionary to decode, and a viewer cannot ask for a second file. The tree still shows the frame’s header and blocks up to the first block that cannot be read, labelled as unread, and the issue names the dictionary ID.
- Viewer: the sequences inside a block are not listed one by one (literal length, match length and offset of each); the tree shows the section, its tables and its bitstream as bytes. The FSE tables are shown as their normalised counts, not as state-by-state decoding tables.
- Viewer: the window size is shown but not enforced: offsets are
checked against the data decoded so far, not against
Window_Size, and block sizes against 128 KB, not against the smaller of the window and 128 KB.
Unknown
- Reference: the contents of a skippable frame’s user data. The RFC gives them no structure, so the explorer shows them as bytes.
Links
Software
Developers
- libzstd – the reference library (C)
- python-zstandard – bindings to libzstd (Python)
Reference
- RFC 8878 – Zstandard Compression and the application/zstd Media Type