richgel999/miniz logo

richgel999/miniz

Free

miniz: Single C source file zlib-replacement library, originally from code.google.com/p/miniz

FreeFree tier
Type
Open Source

About richgel999/miniz

Miniz is a lossless, high-performance data compression library distributed as a single C source file and header. It implements the zlib (RFC 1950) and Deflate (RFC 1951) compressed data format standards, providing a drop-in replacement for the most commonly used zlib APIs without requiring zlib's license. The library supports stream-based processing via a coroutine-style implementation, allowing data to be compressed or decompressed byte by byte. It also includes simple functions for writing .PNG images and reading/writing/appending .ZIP archives. Miniz's compression speed is tuned to be comparable to zlib, and it offers a specialized real-time compressor that competes well with fastlz and minilzo. The low-level compressor (tdefl) and decompressor (tinfl) use simple state structs that can be saved/restored with memcpy and do not allocate heap memory. The entire inflater is implemented in a single ~550-line coroutine function (miniz_tinfl.c). Miniz is MIT licensed, portable (tested with GCC, Clang, and Visual Studio), and can be easily configured via preprocessor defines.

Key Features

Single C source and header file, easy to integrate into any project
Implements zlib (RFC 1950) and Deflate (RFC 1951) compressed data format standards
Drop-in replacement for the most commonly used zlib APIs
Stream-based processing via coroutine-style implementation (single byte at a time supported)
Low-level compressor (tdefl) and decompressor (tinfl) with no heap memory allocation
Supports writing .PNG format image files
Supports reading, writing, and appending .ZIP format archives
Real-time compressor optimized for speed comparable to fastlz/minilzo
Portable and tested with GCC, Clang, and Visual Studio
MIT licensed and completely independent of zlib (no license conflicts)

Pros & Cons

Pros
  • Single-file integration reduces build complexity
  • MIT licensed, permissive and no dependency on zlib's license
  • Stream-based processing allows handling of data in small chunks
  • Low-level API can be used without heap allocation, ideal for constrained environments
  • Provides both compression/decompression and archival (ZIP) functionality in one library
  • Performance competitive with zlib and faster than minilzo at level 1
  • Portable across major compilers and platforms
Cons
  • Single-threaded only; no built-in parallel compression support
  • Compression ratio and speed may not match zlib's heavily optimized implementations at all levels
  • Documentation is minimal, relying primarily on the README and source comments
  • Limited to zlib/Deflate formats; no support for newer compression standards (e.g., Brotli, Zstd)

Best For

Embedded systems requiring a small, self-contained compression libraryGame development for asset compression and archive managementMobile applications where zlib compatibility is needed without zlib license obligationsProjects that need to create or manipulate .ZIP archives programmaticallyReal-time data compression in streaming or low-latency scenarios