Unified API
One interface for all compression algorithms. Learn once, use any codec. Switch codecs with a single line change.
compressionz is a fast, ergonomic compression library for Zig with a unified API across multiple codecs. One interface for LZ4, Snappy, Zstd, Gzip, Brotli, and more.
| Metric | Value |
|---|---|
| LZ4 Compression | 36 GB/s |
| Zstd Throughput | 12 GB/s |
| Supported Codecs | 7 |
| System Dependencies | 0 |
const cz = @import("compressionz");
// Compress with any codecconst compressed = try cz.compress(.zstd, data, allocator);defer allocator.free(compressed);
// Decompressconst original = try cz.decompress(.zstd, compressed, allocator);defer allocator.free(original);Same API for all codecs. Just change .zstd to .lz4, .gzip, .snappy, or .brotli.
Unified API
One interface for all compression algorithms. Learn once, use any codec. Switch codecs with a single line change.
Blazing Fast
Pure Zig LZ4 and Snappy with SIMD optimizations achieve 36+ GB/s compression throughput.
Zero Dependencies
All C libraries are vendored. No brew install, no apt-get. Works on any platform Zig supports.
Production Ready
Streaming, dictionaries, checksums, decompression bomb protection. Everything you need.
| Codec | Speed | Ratio | Streaming | Implementation |
|---|---|---|---|---|
| Zstd | 12 GB/s | 99.9% | Yes | Vendored C |
| LZ4 Raw | 36 GB/s | 99.5% | No | Pure Zig |
| LZ4 Frame | 4.8 GB/s | 99.3% | Yes | Pure Zig |
| Snappy | 31 GB/s | 95.3% | No | Pure Zig |
| Gzip | 2.4 GB/s | 99.2% | Yes | Vendored C |
| Brotli | 1.3 GB/s | 99.9% | Yes | Vendored C |
Process large files without loading everything into memory. Integrates with Zig’s standard Reader/Writer interfaces.
Dramatically improve ratios for small data with known patterns. Supported by Zstd, Zlib, and Deflate.
Compress into pre-allocated buffers for zero-allocation hot paths. Perfect for embedded or real-time systems.
Automatically detect compression format from magic bytes. Decompress unknown data without guessing.
Read and write ZIP and TAR archives with simple, ergonomic APIs. Extract or create with one function call.
Set maximum output size limits to protect against malicious compressed data.