Compression

zlib.brotliDecompress()

Decodes Brotli bytes. Set output limits for bounded convenience decoding; invalid compressed bytes must be treated as an error. Tested on Node.js 22.16.0. Example output (one line per entry): ["catalog"].

Formal Syntax & Structure

nodejs syntaxnodejs
zlib.brotliDecompress(buffer[, options], callback)

Parameters & Attributes

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

Return Value

undefined

Decoded Buffer via callback.

Working Example

Example Snippetnodejs
import { brotliCompressSync, brotliDecompress } from 'node:zlib';import { promisify } from 'node:util';console.log((await promisify(brotliDecompress)(brotliCompressSync('catalog'), { maxOutputLength: 64 })).toString());
Node.js Reference