zlib is a general-purpose data compression library for the zlib, deflate, and gzip formats described in RFCs 1950–1952. Programs link it to compress and decompress streams and to work with gzip files.
Overview
zlib provides compression and decompression for application data using the zlib wrapper, raw deflate, and gzip formats standardized in RFCs 1950 through 1952. The library exposes stream-oriented deflate and inflate APIs plus higher-level gzip file helpers such as gzopen, and documents its public interface in zlib.h.
The implementation is intended to be thread-safe, with caveats noted in the project FAQ. Alongside the core codec, the distribution includes usage examples and optional contributed code such as minizip for reading and writing Zip archives on top of zlib.
Typical integration is by compiling or linking the library into a program on the target system. The maintainers document build paths for Unix-style systems via configure and make, dedicated Windows makefiles and DLL builds, and other environments such as VMS. Language bindings and built-in wrappers exist in several ecosystems mentioned on the project site, but the product itself is the C library sources.
The project is maintained independently of the separate Linux zlibc compressing file-I/O library. deflate builds on work by Phil Katz; zlib and deflate specifications were written by L. Peter Deutsch, with ongoing development credited to Jean-loup Gailly and Mark Adler.
Key features
- RFC 1950–1952 zlib, deflate, and gzip formats
- Stream deflate and inflate APIs
- gzip file read and write helpers
- Thread-safe core design
- compress and uncompress convenience routines
- Optional minizip Zip archive support
- Documented C API in zlib.h
- Wide platform build support
Use cases
- Compressing in-memory or networked data streams
- Reading and writing gzip-encoded files
- Embedding deflate compression in applications
- Handling Zip archives via contributed minizip code