zlib
A widely used C library for DEFLATE and gzip compression; in Node.js, node:zlib also provides Brotli.
In more detail
node:zlib offers one-call functions such as gzipSync() and gunzipSync(), promise and callback versions, and streams such as createGzip(). The Sync versions block the event loop, so servers should use the streaming or asynchronous forms.
Related terms
- gzip — The command that compresses a single file and replaces it with a smaller .gz version; gunzip reverses it.
- Brotli — A compression format designed by Google that usually shrinks text more than gzip, at the cost of slower compression at high quality settings.
- DEFLATE — The compression algorithm inside gzip and zip files, which replaces repeated byte sequences with short references to earlier ones.
- compression — Encoding data in fewer bytes by removing repetition, so it takes less space and less time to send.
Taught in
- Cryptographic Primitives: node:crypto & Ciphers — Node.js Internals & Backend Services
- Native Compression: node:zlib & Streaming Codecs — Node.js Internals & Backend Services