---
source: https://iinventedlight.com/library/notes/python-compression-zstd.md
title: "Python compression.zstd: Zstandard compression and decompression"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, compression.zstd — Compression compatible with the Zstandard format; CPython, compression.zstd documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-compression-zstd"
tags: [python, zstd, zstandard, compression, decompression]
client: Librarian
sources:
  - id: S1
    title: "compression.zstd — Compression compatible with the Zstandard format"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/compression.zstd.html
    accessed: 2026-11-26
    license: "PSF License Version 2"
  - id: S2
    title: "compression.zstd documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/compression.zstd.rst
    accessed: 2026-11-26
    license: "PSF License Version 2"
---
# Python compression.zstd: Zstandard compression and decompression
**Answer:** compression.zstd compresses and decompresses data in the Zstandard format.

## What the algorithm is for

The module provides classes and functions for compressing and decompressing data.

The zstd manual describes Zstandard as a fast lossless compression algorithm.

It targets real-time compression scenarios at zlib-level and better compression ratios.

A file interface can read and write the contents of .zst files.

## Classes and helpers

ZstdCompressor and ZstdDecompressor classes are for incremental compression.

The compress and decompress functions are for one-shot compression.

open and ZstdFile read and write compressed files.

Raw zstd compressed streams are supported as well.

## See also

- [python-zlib](https://iinventedlight.com/library/notes/python-zlib/)
- [python-gzip](https://iinventedlight.com/library/notes/python-gzip/)
- [python-lzma](https://iinventedlight.com/library/notes/python-lzma/)

## Claims

- id: C1
  claim: The module compresses and decompresses data using Zstandard.
  source: S1
  evidence: "compressing and decompressing data using the Zstandard"

- id: C2
  claim: Zstandard targets real-time compression scenarios.
  source: S1
  evidence: "targeting real-time compression scenarios"

- id: C3
  claim: open and ZstdFile read and write compressed files.
  source: S2
  evidence: "reading and writing compressed files"

- id: C4
  claim: Raw zstd compressed streams are also supported.
  source: S2
  evidence: "raw zstd compressed streams"

## Sources

- [S1] compression.zstd — Compression compatible with the Zstandard format. Python Software Foundation. https://docs.python.org/3/library/compression.zstd.html . License: PSF License Version 2. Accessed 2026-11-26.

- [S2] compression.zstd documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/compression.zstd.rst . License: PSF License Version 2. Accessed 2026-11-26.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, compression.zstd — Compression compatible with the Zstandard format; CPython, compression.zstd documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
