Pako implements deflate, gzip, and inflate in JavaScript for Node.js and browsers. Output can match bytes from reference zlib and Node’s zlib implementation.
Overview
Pako is a JavaScript port of zlib-style compression and decompression. It exposes high-level deflate and inflate helpers plus streaming Deflate and Inflate classes for chunked input without throwing on broken streams in the simple wrappers.
The library aims for byte-compatible deflate and gzip output with original zlib and Node.js zlib, small minified browser bundles, and competitive speed in modern JS engines. Deflate-only and inflate-only builds shrink bundle size further when you need only one direction.
Strings can be passed to deflate, which recodes them as UTF-8 before compression; inflate can return text with a toText option. The API supports ES module imports, CommonJS require, and namespace imports for the full surface.
Some low-level zlib routines are intentionally omitted, and high-level wrapper classes may not support every flush mode from native zlib.
Key features
- Deflate and inflate for Uint8Array data
- Gzip-compatible compression path
- Binary-compatible zlib output
- Chunked Deflate and Inflate classes
- UTF-8 string compression helpers
- Small browser bundle builds
- ESM and CommonJS module usage
Use cases
- Compressing data in browser applications
- Gzip-style payloads in Node.js services
- Streaming compression without exceptions
- JSON string compression over the wire