Codec-Specific APIs
Each codec exposes only its supported features. Type-safe, discoverable interfaces with no runtime codec selection overhead.
compressionz is a fast, ergonomic compression library for Zig with codec-specific APIs. Each codec module exposes only the features it supports, providing type-safe, discoverable interfaces 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 Zstdconst compressed = try cz.zstd.compress(data, allocator, .{});defer allocator.free(compressed);
// Decompressconst original = try cz.zstd.decompress(compressed, allocator, .{});defer allocator.free(original);Each codec has its own module with tailored APIs. Use cz.zstd, cz.lz4.frame, cz.lz4.block, cz.gzip, cz.snappy, or cz.brotli.
Codec-Specific APIs
Each codec exposes only its supported features. Type-safe, discoverable interfaces with no runtime codec selection overhead.
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 Block | 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 and Zlib.
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.