zstd.zig
zstd.zig is a native Zstandard implementation for Zig.
This project originally started as C bindings to Zstandard, but I wanted to build something that felt more native to Zig, with direct control over memory, allocators, ownership, codec state, and the API itself.
I also wanted to avoid depending on the upstream C implementation and have the library work naturally across different Zig targets. The original Zstandard codebase by Facebook and the Zstandard format were used as references while developing the native Zig implementation.
The implementation currently supports:
-
Zstandard compression and decompression
-
Streaming compression and decompression
-
All 9 match-finding strategies
-
FSE and Huffman coding
-
Long-distance matching
-
Static and trained dictionaries
-
Reusable compression and decompression contexts
-
Legacy frame decoding
-
Application-managed concurrency
-
Frame inspection
Zig 0.17.0 currently doesn’t provide complete native Zstandard support in the standard library. It has a partial native decompressor, but no Zstandard compressor, which was one of the reasons I wanted to build this.
Project: GitHub - muhammad-fiaz/zstd.zig: Native Zig implementation of Zstandard (zstd), a fast, lossless real-time compression algorithm. · GitHub
Documentation: zstd.zig | Native Zig Compression Library
Supported Zig versions
-
Zig 0.17.0
-
Zig 0.16.0
AI / LLM usage disclosure
I used AI/LLM tools minimally during development, mainly for occasional code assistance, debugging, and documentation.
The project was not purely vibe coded. I designed and implemented the architecture and core functionality myself, and reviewed and tested the changes throughout development.
I’d really appreciate any feedback, suggestions, or ideas from the Zig community. If you have thoughts on the API, implementation, performance, or anything that could be improved, I’d love to hear them.