zstddecompress Synchronous

  • crypt.zstd.decompress

Restore data stored in a Zstandard frame. This is the counterpart to zstdcompress, so it belongs at the read side of a Zstandard-backed file or message.

Syntax
Luau
zstddecompress(data: string) -> string

Parameters

Function parameters
ParameterTypeDescription
datastringZstandard-compressed bytes.

Returns

string

The decompressed byte string. Corrupt data or an unsupported frame raises an error.

Usage notes

The function does not auto-detect LZ4 or Base64. Decode an outer Base64 layer first if you added one for text storage.

Limits

ResourceLimitWhat happens
Compressed inputThe largest output zstdcompress can produce for 512 MiBA larger string raises an error.
Decompressed output512 MiBA larger result raises an error rather than being truncated.
Decoder window512 MiBA frame that needs a larger window raises an error.

A small frame can expand into a much larger string, so use pcall when the source is untrusted.

Example

Example
Luau
local packed = zstdcompress("a saved note")
local ok, note = pcall(zstddecompress, packed)
if ok then print(note) end