FluxyAPIFluxyAPI
BlocksCompression & Encoding

Compress

Reduce the size of a string using various compression algorithms.

The Compress block allows you to shrink large strings into a more compact format. This is particularly useful for optimizing storage, reducing bandwidth when sending data to external APIs, or handling long payloads that exceed size limits.

Core Concept

Think of compression like a "travel vacuum bag" for your data. You take a bulky item (your string), suck the air out (apply an algorithm), and it takes up much less space. To read the content later, you must "unzip" or decompress it back to its original state.

Compression Formats

This block supports several popular algorithms:

  • LZ-String: Optimized for storing data in localStorage or URLs.
  • Gzip/Deflate: Standard web compression formats.
  • Brotli: A modern, high-performance algorithm often providing better compression ratios than Gzip.

Configuration

FieldRequiredDescription
Input StringThe text you want to compress. Supports variables like {request.body.data}.
Compression TypeThe algorithm to use: lzstring, gzip, deflate, or brotli.
Output VariableThe name of the variable where the resulting Base64-encoded compressed string will be stored.

Error Handling

  • COMPRESS_INPUT_MISSING — Triggered when no input string is provided.
  • COMPRESS_TYPE_MISSING — Triggered when no compression algorithm is selected.
  • COMPRESS_VAR_MISSING — Triggered when the output variable name is not defined.
  • COMPRESS_TYPE_UNSUPPORTED — Triggered if an invalid algorithm is passed (rarely occurs via UI).
  • COMPRESS_RUNTIME_ERROR — Triggered if the compression process fails unexpectedly.

Example: Optimizing API Paylogs

If you are sending a very large JSON payload to an external logging service, you can compress it first to save on bandwidth and costs.

  1. Input String: Use a variable containing your large text, e.g., {large_json_string}.
  2. Compression Type: Select Brotli for the best performance.
  3. Output Variable: Set it to compressed_payload.

After the block runs, {compressed_payload} will contain a Base64 string that is significantly smaller than the original input, ready to be sent in an HTTP request.

On this page