lz4compress Synchronous

  • crypt.lz4.compress
  • crypt.lz4compress
  • lz4.compress

Pack a byte string as an LZ4 block for fast storage or transfer. It works best when the input contains repeated material; short inputs can grow instead of shrinking.

Syntax
Luau
lz4compress(data: string) -> string

Parameters

Function parameters
ParameterTypeDescription
datastringText or binary bytes to compress.

Returns

string

An LZ4 block as a binary string. Save or transmit it as bytes, or Base64-encode it for a text-only destination.

Usage notes

Keep the compression format with the saved data so the reader can choose lz4decompress. This call does not create a ZIP file.

Example

Example
Luau
local original = string.rep("inventory=full;", 40)
local packed = lz4compress(original)
print(#original, #packed)
assert(lz4decompress(packed) == original)
Kawaii documentation