Uses compression.zstd (Python 3.14+) or zstandard (Python < 3.14) to extract Zstandard-compressed files and archives.
.zstfiles (raw Zstandard-compressed single files).tar.zstarchives- mislabeled plain tar files (for example, a
.tarfile accidentally named.zst)
The extractor is implemented in extract_zst.py.
Streams decompression to not overflow memory for large files. Uses safer tar extraction filtering on supported Python versions.
- Python 3.9+
- For Python < 3.14:
zstandard
The script includes inline metadata for uv run --script users.
uv run --script extract_zst.pyRun with Python:
python .\extract_zst.py <archive.zst> <output_directory>Examples:
python .\extract_zst.py .\hello.txt.zst .
python .\extract_zst.py .\test.tar.zst .\outA real .tar.zst is a tar stream compressed with Zstandard.
If your tar supports zstd directly:
tar --zstd -cf test.tar.zst hello.txt goodbye.txtPortable two-step approach:
tar -cf test.tar hello.txt goodbye.txt
zstd -19 -T0 --rm test.tar -o test.tar.zstQuick validation:
zstd -t test.tar.zst
tar --zstd -tf test.tar.zstThis repository uses PyTest.
pytestextract_zst.py: extractor implementation and CLI entrypointtest_extract_zst.py: pytest test suitehello.txt.zst,test.tar.zst: sample archives for local testing
Thanks