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.
Luau
zstddecompress(data: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
data | string | Zstandard-compressed bytes. |
Returns
stringThe 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
| Resource | Limit | What happens |
|---|---|---|
| Compressed input | The largest output zstdcompress can produce for 512 MiB | A larger string raises an error. |
| Decompressed output | 512 MiB | A larger result raises an error rather than being truncated. |
| Decoder window | 512 MiB | A 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
Luau
local packed = zstdcompress("a saved note")
local ok, note = pcall(zstddecompress, packed)
if ok then print(note) end