Compression
zlib.gunzip()
Decodes gzip bytes asynchronously. Use an output cap for bounded convenience decoding and also limit input and concurrency. Tested on Node.js 22.16.0. Example output (one line per entry): ["book"].
Formal Syntax & Structure
nodejs syntaxnodejs
zlib.gunzip(buffer[, options], callback)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| buffer | Buffer | string | TypedArray | DataView | ArrayBuffer | Compressed data. |
| options | object | Decompression options. |
| callback | Function | Error-first completion callback. |
Return Value
undefined
Decoded Buffer delivered by callback.
Working Example
Example Snippetnodejs
import { gzipSync, gunzip } from 'node:zlib';import { promisify } from 'node:util';const decoded = await promisify(gunzip)(gzipSync('book'), { maxOutputLength: 64 });console.log(decoded.toString());