zstdcompress Synchronous

  • crypt.zstd.compress

Compress a byte string using Zstandard and an optional compression level. Use it for compact storage of larger text or binary content. Compression returns binary data, so Base64-encode it separately if the destination only accepts text.

Syntax
Luau
zstdcompress(data: string, level: number?) -> string

Parameters

Function parameters
ParameterTypeDescription
datastringUncompressed bytes.
levelnumber?Integer from -131072 through 22. Defaults to 1.

Returns

string

Compressed bytes as a Luau string.

Example

Example
Luau
local packed = zstdcompress("hello hello hello", 1)
print(zstddecompress(packed)) -- hello hello hello
Kawaii documentation