Compression

zlib.inflateSync()

Decodes zlib-wrapped DEFLATE data synchronously. Bound output size and avoid synchronous decoding of untrusted large inputs in a server. Tested on Node.js 22.16.0. Example output (one line per entry): ["book"].

Formal Syntax & Structure

nodejs syntaxnodejs
zlib.inflateSync(buffer[, options])

Parameters & Attributes

NameTypeDescription
bufferBuffer | string | TypedArray | DataView | ArrayBufferCompressed input.
optionsobjectDecompression options.

Return Value

Buffer

Decoded bytes.

Working Example

Example Snippetnodejs
import { deflateSync, inflateSync } from 'node:zlib';console.log(inflateSync(deflateSync('book'), { maxOutputLength: 16 }).toString());
Node.js Reference