explaingit

madler/zlib

6,857CAudience · developerComplexity · 3/5LicenseSetup · moderate

TLDR

A foundational C library for compressing and decompressing data, used inside operating systems, browsers, and databases worldwide. It implements the gzip and deflate formats defined in open internet standards.

Mindmap

mindmap
  root((zlib))
    What it does
      Data compression
      Decompression
      Gzip support
    Formats
      deflate RFC 1951
      zlib RFC 1950
      gzip RFC 1952
    Integration
      C API via zlib.h
      Unix configure make
      Windows builds
    Audience
      C developers
      Systems programmers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add gzip compression to a C or C++ application by linking against zlib and calling its compress and decompress functions.

USE CASE 2

Read and write .gz files in your program using zlib gzip-format support.

USE CASE 3

Implement deflate-format stream compression in a network protocol or file format following open RFC standards.

Tech stack

C

Getting it running

Difficulty · moderate Time to first run · 30min

Builds with standard configure and make on Unix, Windows requires a separate build configuration included in the source.

Use freely in any software including commercial products, you do not need to include an attribution notice in your end product.

In plain English

zlib is a data compression library written in C. It has been in continuous use since 1995 and is one of the most widely distributed pieces of software in existence, built into operating systems, web browsers, file archivers, databases, and countless other programs. When software needs to make files smaller for storage or transmission, zlib is often the library doing that work behind the scenes. The library implements a compression format called deflate, which is also the basis of the gzip format used for .gz files and the zlib envelope format. These formats are defined in public internet standards documents (RFCs 1950, 1951, and 1952) rather than being proprietary, so data compressed with zlib can be read by any conforming implementation. zlib is designed to be used by developers as a component in their own software. It provides functions for compressing and decompressing data and is documented through a header file called zlib.h. The library comes with example programs and a test suite. It builds on most Unix-like systems with a standard configure and make process, and the source includes additional build configurations for Windows and other platforms. The library is thread-safe with some caveats noted in the FAQ. It does not include any third-party code and has been written entirely by Jean-loup Gailly and Mark Adler. Language interfaces exist for Python, Java, Perl, and Tcl, though those are maintained separately. zlib is free to use in any software, including commercial products, under a permissive license that does not require the usual open-source attribution to be included in the end product. The library's home page and FAQ are at zlib.net.

Copy-paste prompts

Prompt 1
How do I add zlib to my C project with CMake and use it to compress a buffer of bytes in memory?
Prompt 2
Show me a minimal C example that reads a .gz file and decompresses it to stdout using zlib.
Prompt 3
I am implementing HTTP compression in a C server. Which zlib functions handle deflate-format streams?
Prompt 4
How do I build zlib from source on Linux and link it statically into my C application?
Open on GitHub → Explain another repo

← madler on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.