> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# lz4compress

> Compresses Lua string bytes with LZ4 block compression and returns the raw compressed bytes as a Lua string.

<div className="real-function-page">
  ```lua theme={null}
  lz4compress(data: string): string
  ```

  ## Aliases

  * `crypt.lz4compress`
  * `crypt.lz4.compress`
  * `lz4.compress`

  ## Arguments

  <ParamField path={"data"} type={"string"} required>
    Lua string bytes passed to LZ4 block compression.
  </ParamField>

  ## Returns

  <ResponseField name={"compressed"} type={"string"}>
    Raw compressed bytes returned as a Lua string. The original size is not stored in the output.
  </ResponseField>

  ## Example

  Compress Lua string bytes and restore them by passing the original size.

  ```lua theme={null}
  local source = string.rep("Real Docs ", 100)
  local compressed = lz4compress(source)
  local restored = lz4decompress(compressed, #source)

  print(#source, #compressed, restored == source)
  ```
</div>
