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
| Name | Type | Description |
|---|---|---|
| buffer | Buffer | string | TypedArray | DataView | ArrayBuffer | Compressed input. |
| options | object | Decompression options. |
| callback | Function | Completion 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());