Library / SDK
richgel999/miniz avatar
richgel999/miniz

miniz: an independent implementation that shares zlib's algorithms on purpose

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

2,922 stars439 forksC++MIT

At a glance

What is it?
miniz is a single file C library that speaks the zlib and Deflate formats without carrying zlib's licensing requirements, and it also ships PNG writing and ZIP archive handling. The readme is unusually candid about where it stops: no encrypted archives, minimal documentation, and a patent position built on using the same core algorithms as zlib.
Who is it for?
miniz fits a project that needs the zlib wire format in one droppable file and would rather not carry zlib's licence, particularly an embedded or game codebase that also wants PNG output and ZIP handling from the same source. It does not fit a project that needs encrypted archives, that wants a finished archiver rather than archive primitives, or that expects documentation beyond comments and six examples.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 6 days ago.
What is it written in?
Mainly C++, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • richgel999/miniz2,922 ★ · +35
Star history
Repository2026-10-042026-11-15
richgel999/miniz2.9k2.9k

35 Stars in the last 42 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The single source file is a build product assembled from eight

The headline is a single source file, and the readme is careful about how that file comes to exist. Releases are published as a pair of miniz.c and miniz.h files which can be simply added to a project, and to create that pair the different source and header files are amalgamated during build, with a link to the SQLite amalgamation page as the model. The tree shows what goes into it: miniz_common.h, miniz_tdef.c and miniz_tdef.h for the low level compressor, miniz_tinfl.c and miniz_tinfl.h for the decompressor, miniz_zip.c and miniz_zip.h for the archive layer, plus amalgamate.sh at the top level. So miniz.c is a generated artifact and the eight files behind it are the sources a fork should edit. Four consumption paths sit alongside: CMakeLists.txt with CMakePresets.json and a Config.cmake.in template, meson.build, a miniz.pc.in file for pkg-config, or the amalgamation output dropped into a project directly.

The archive API stops just short of being an archiver

The ZIP support is described as a fairly complete but totally optional set of archive manipulation and extraction APIs, and the stated purpose is to solve common problems in embedded, mobile or game development. Then comes the sentence that sets the boundary: the archive APIs are purposely just enough to write an entire archiver given a bit of additional higher-level logic. In other words the traversal, the headers and the compression are provided, and the program that decides what goes into the archive and in what order is not. That is a deliberate line rather than an omission, and it is the reason the PNG and ZIP portions are described separately from the compression core in the first place, since both are conveniences layered on the same primitives. The readme also credits the PNG writer function to Alex Evans rather than to the maintainer, so the two non compression features have different origins inside the same file.

Only one comparison on the page carries a number

The feature list claims miniz fills a single threaded performance versus compression ratio gap between several popular real time compressors and zlib, and then gives exactly one measurement. At level 1, miniz.c compresses around 5 to 9 percent better than minilzo, but is approximately 35 percent slower. Everything else is directional: at levels 2 through 9, miniz.c is designed to compare favorably against zlib's ratio and speed, with no ratio, no speed and no sample named. The page also mentions a specialized real time compressor function designed to compare well against fastlz and minilzo, again without figures, and points to the miniz performance comparison page for example timings without giving a link to it. So the one hard number on the page describes the level a reader is least inclined to ship in, and the claim about the mid range levels, which is the one most deployments would use, is an intention rather than a measurement.

The inflater is one coroutine function and the low level codec avoids the heap

Two design decisions are stated as the reason the streaming API is usable in small systems. The first is that miniz is not a block based compressor: it fully supports stream based processing using a coroutine style implementation, and the zlib style API functions can be called a single byte at a time if that is all you have. The second is that the low level compressor, named tdefl, and the decompressor, named tinfl, have simple state structs which can be saved and restored as needed with simple memcpy calls, and that the low level codec APIs do not use the heap in any way. Memory therefore comes from the caller's own allocation and the caller's own copy, which is what makes suspension across an interrupt or a task switch practical. The entire inflater, including optional zlib header parsing and Adler-32 checking, is implemented in a single function as a coroutine, and that function is separately available in a source file of roughly 550 lines, miniz_tinfl.c.

Encrypted archives are the one feature declined on purpose

The Known Problems section has two entries and the first is a refusal rather than a gap. There is no support for encrypted archives, followed by the author's own assessment of whether that matters: not sure how useful this stuff is in practice. That is the whole of the statement, with no plan, no partial work and no alternative named. For a ZIP library that otherwise advertises a fairly complete set of manipulation and extraction APIs, this is the single largest functional gap, and it is the one place where the readme's tone turns from description to judgement. It is worth setting against the licensing claim in the same document: miniz is an independent implementation specifically so that zlib's licensing requirements do not apply, so a reader looking for a clean-room zlib replacement gets exactly that, and a reader who also needs password protected archives has to bring their own.

Minimal documentation is listed as a known problem, with six examples as the mitigation

The second known problem is the documentation. It is called minimal, and the assumption behind it is stated plainly: that the user is already familiar with the basic zlib API. The author's own to-do is an API wiki, and the interim answer is that key comments have been placed before each enum and API. The other half of the interim answer is the examples directory, which holds six files, example1.c through example6.c, described as demonstrating how to use the module's major features. So the learning path is: know zlib, read the header comments, run the six examples. There is also a tests/ directory and a test.sh at the top level for the other half of the correctness question, and a .clang-format file, which together suggest the formatting and the test invocation are settled even where the prose is not.

The patent position is to share zlib's core algorithms deliberately

The Patents section answers a question nobody has to guess at. The author was asked whether miniz avoids patent issues, and the answer is that it does not try to: miniz purposely uses the same core algorithms as the ones used by zlib, with the compressor using vanilla hash chaining as described in the Deflate specification, and a link to the gzip FAQ alongside it. The reasoning that follows is explicitly offered as opinion, that if miniz falls prey to a patent attack then zlib and gzip are likely to be at serious risk too. Read next to the licensing claim, the two positions are consistent and pull in opposite directions on purpose. The library is an independent implementation so that zlib's licensing requirements do not apply, and it is deliberately not a novel algorithm so that it shares whatever exposure zlib already carries. Choosing a different compression scheme to dodge that would have meant giving up the drop-in API claim.

vcpkg holds the documented install path and its version can drift

There are two installation routes and they have different owners. The direct route is the releases page, which publishes the miniz.c and miniz.h pair, or a cmake or meson module, or a build system of your choice. The package manager route is vcpkg, and the page spells out five shell steps:

bash
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install miniz

The last two lines are the older integrate style of vcpkg usage, and the bootstrap step is given only as the shell script form with no Windows equivalent on the page. What matters more is who maintains the result: the miniz port in vcpkg is kept up to date by Microsoft team members and community contributors, and if the version is out of date the page asks for an issue or pull request against the vcpkg repository rather than this one. So the version you get through the package manager is maintained outside the project and can lag the tags. The release list shows 3.1.0 on 2025-09-21, 3.1.1 on 2026-02-03 and 3.1.2 on 2026-07-01, so pin deliberately rather than trusting the port.

Editorial conclusion

miniz fits a project that needs the zlib wire format in one droppable file and would rather not carry zlib's licence, particularly an embedded or game codebase that also wants PNG output and ZIP handling from the same source. It does not fit a project that needs encrypted archives, that wants a finished archiver rather than archive primitives, or that expects documentation beyond comments and six examples. Before committing, check that the compression level you need is one the page actually numbers, since only level 1 against minilzo is quantified and the zlib comparison is deferred elsewhere, and check the vcpkg port version against the tags, because that port is maintained outside this repository and can lag.

Frequently asked questions

what is miniz

It is a lossless data compression library in a single source file that implements the zlib, RFC 1950, and Deflate, RFC 1951, compressed data format standards. It is a completely independent implementation, so zlib's licensing requirements do not apply, and it is MIT licensed.

miniz vs zlib

miniz implements the same RFC 1950 and RFC 1951 formats and is described as a drop-in replacement for zlib's most used APIs, tested in projects that use zlib such as libpng and libzip. Compression speed has been tuned to be comparable to zlib's, at levels 2 through 9 miniz is designed to compare favorably on ratio and speed, and the compressor deliberately uses the same vanilla hash chaining as zlib.

How do I install miniz from vcpkg?

Clone the vcpkg repository, run ./bootstrap-vcpkg.sh, then ./vcpkg integrate install and ./vcpkg install miniz. Alternatively, releases publish a miniz.c and miniz.h pair that can simply be added to a project, or the library can be used as a cmake or meson module.

Does miniz support encrypted ZIP archives?

No. Encrypted archives are the first entry under Known Problems, described as not supported, with the note that it is not sure how useful this stuff is in practice. There is no partial support and no alternative named.

What are the known problems with miniz?

Two are listed: no support for encrypted archives, and minimal documentation. The documentation entry adds that the assumption is the user is already familiar with the basic zlib API, that an API wiki is still to be written, and that six examples are included as an interim measure.

How does miniz compare to minizip?

The page makes no comparison with minizip. The only libraries it measures itself against are zlib, and in one place minilzo and fastlz, where at level 1 miniz compresses around 5 to 9 percent better than minilzo but is approximately 35 percent slower.

Official sources

  1. Issues
  2. License: MIT
  3. README
  4. Releases
  5. richgel999/miniz on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/richgel999-miniz.svg)](https://hysenlabs.com/projects/richgel999-miniz)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/richgel999-miniz.svg)](https://hysenlabs.com/projects/richgel999-miniz)

Was this useful?