nodes / builtin / datatransformation
Compression
Compress or decompress binary data with gzip
Shrink a file into a .gz file, or unpack a .gz file back into its content.
What it does
Section titled “What it does”Compression works on the file attached to each item (its binary data), one item at a time:
- Compress (gzip) reads the attached file in Binary Field and replaces it with a gzip file (
application/gzip). If the item has no attached file, it compresses the text in Text to compress instead. - Decompress (gunzip) reads a gzip file from Binary Field and replaces it with the unpacked file. With Decode to text on, it puts the unpacked content on the item as plain text instead.
It handles the gzip format (.gz) only. It cannot create or open .zip archives, which hold several files.
To protect your browser, decompression stops with an error if the result grows past 50 MB, or past 200 times the size of the compressed input.
When to use it
Section titled “When to use it”- Unpack a
.gzexport (a log, a JSON or CSV dump) you downloaded, so the next node can read it. - Compress a large text or file before you upload it or send it to an API that accepts gzip.
- For
.ziparchives, use a different tool: this node cannot read them.
Inputs and settings
Section titled “Inputs and settings”| Setting | Type | What it does |
|---|---|---|
| Operation | Choice | Compress (gzip) or decompress (gunzip) the input. Options: Compress (gzip), Decompress (gunzip). Default: Compress (gzip) |
| Binary Field | Text | The $binary slot to read the input bytes from and write the result to. Default: data |
| Text to compress | Long text | For gzip only: text to compress when the item has no $binary attachment. |
| Output file name | Text | For gzip: name of the produced file. Left empty, the source name with a ".gz" suffix (or "data.gz") is used. |
| Output MIME type | Text | For gunzip: content type recorded on the decompressed file. Left empty, application/octet-stream is used. |
| Decode to text | Toggle | For gunzip: place the decompressed content as UTF-8 text on the item (in the binary field name) instead of a $binary attachment. Default: Off |
- Leave Binary Field at
dataunless the previous node stored its file under another name. - Text to compress accepts expressions, for example
{{ $input.report }}. - When decompressing, a name ending in
.gzloses that suffix:export.json.gzbecomesexport.json. Set Output MIME type (for exampletext/csv) so later nodes know what the file is.
Outputs
Section titled “Outputs”-
Output
Each item keeps its other fields and gets the new file plus fileName, mimeType and size. With Decode to text on, the item instead gets the text in a field named after Binary Field (by default data), so you can read it with {{ $input.data }}.
Dependencies and credentials
Section titled “Dependencies and credentials”None. This node needs no connection and has no slots for other nodes.
Example workflow
Section titled “Example workflow”- HTTP Request downloads
https://example.com/export.json.gzwith Response format set to file. - Compression with Operation set to Decompress (gunzip) and Decode to text on.
- JSON parses
{{ $input.data }}into fields you can use.
Common issues
Section titled “Common issues”- “Nothing to compress. Connect an item carrying a $binary attachment, or fill in “Text to compress”.“ The item has no file under Binary Field and the text box is empty. Check the field name, or fill in Text to compress.
- “No binary to decompress in “$binary.data”.“ Decompressing needs an attached file. Make sure the previous node outputs a file, and that Binary Field matches its name.
- “Could not decompress the input as gzip. Ensure it is valid gzip data.” The file is not gzip. It may be a plain file or a
.ziparchive, which this node cannot open. - “Decompressed output exceeded the … ceiling; refusing (possible zip bomb).” or “Decompression ratio exceeded 200×”. The unpacked content is too large, or the file is suspiciously over-compressed. Use a smaller file.
Related nodes
Section titled “Related nodes”- Extract From File: read CSV, JSON or text from the unpacked file.
- Convert to File: turn data into a file before compressing it.
- Http Request: download a
.gzfile, or upload the compressed one.