---
title: Compression
description: 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

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

* Unpack a `.gz` export (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 `.zip` archives, use a different tool: this node cannot read them.

## Inputs and settings

* Leave **Binary Field** at `data` unless the previous node stored its file under another name.
* **Text to compress** accepts expressions, for example `{{ $input.report }}`.
* When decompressing, a name ending in `.gz` loses that suffix: `export.json.gz` becomes `export.json`. Set **Output MIME type** (for example `text/csv`) so later nodes know what the file is.

## Outputs

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

None. This node needs no connection and has no slots for other nodes.

## Example workflow

1. [HTTP Request](/nodes/builtin/core/http-request/) downloads `https://example.com/export.json.gz` with **Response format** set to *file*.
2. Compression with **Operation** set to *Decompress (gunzip)* and **Decode to text** on.
3. [JSON](/nodes/builtin/datatransformation/json/) parses `{{ $input.data }}` into fields you can use.

## 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 `.zip` archive, 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

* [Extract From File](/nodes/builtin/datatransformation/extractfromfile/): read CSV, JSON or text from the unpacked file.
* [Convert to File](/nodes/builtin/datatransformation/converttofile/): turn data into a file before compressing it.
* [Http Request](/nodes/builtin/core/http-request/): download a `.gz` file, or upload the compressed one.