High Performance
Optimized implementations of compression algorithms with minimal overhead and efficient memory usage.
Comprehensive compression and archive support for Zig with multiple algorithms and streaming capabilities

const std = @import("std");
const archive = @import("archive");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
// Compress data
const input = "Hello, Archive.zig!";
const compressed = try archive.compress(allocator, input, .gzip);
defer allocator.free(compressed);
// Decompress data
const decompressed = try archive.decompress(allocator, compressed, .gzip);
defer allocator.free(decompressed);
std.debug.print("Original: {s}\n", .{input});
std.debug.print("Compressed: {d} bytes\n", .{compressed.len});
std.debug.print("Decompressed: {s}\n", .{decompressed});
}| Algorithm | Extension | Description | Performance |
|---|---|---|---|
| gzip | .gz | GNU zip with CRC32 | Fast |
| zlib | .zlib | Deflate with Adler32 | Fast |
| deflate | .deflate | Raw deflate | Fastest |
| zstd | .zst | Modern compression | Very Fast |
| lz4 | .lz4 | Ultra-fast compression | Fastest |
| lzma | .lzma | High compression ratio | Slow |
| xz | .xz | LZMA2-based | Slow |
| tar.gz | .tar.gz | TAR + gzip | Fast |
| zip | .zip | ZIP archive format | Fast |
Add Archive.zig to your project with Zig's package manager:
zig fetch --save https://github.com/muhammad-fiaz/archive.zig/archive/refs/tags/0.0.1.tar.gzThen add to your build.zig:
const archive = b.dependency("archive", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("archive", archive.module("archive"));