# Gzip compress and decompress

Compress text with gzip to base64 and see the size saved, or decompress base64 gzip data.

- Endpoint: `POST https://setget.net/v1/tools/gzip` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `gzip`
- Page: https://setget.net/tools/gzip

## Inputs

- `text` (required, string): The text to compress, or base64 gzip data to decompress.
- `action` (optional, string, one of `compress`, `decompress`, default `"compress"`): Compress text, or decompress gzip data.
- `level` (optional, integer, default `6`, range 1..9): Compression effort when compressing, from 1 (fastest) to 9 (smallest).

## Example 1

```json
{"input":{"text":"na na na na na na na na na na na na na na na na Batman!"}}
```

Result:

```json
{"text":"H4sIAAAAAAAA/8tLVMgjBTklluQm5ikCANmXu+U3AAAA","bytes_before":55,"bytes_after":33,"ratio":0.6}
```

## Example 2: Back to text

```json
{"input":{"text":"H4sIAAAAAAAA/8tLVMgjBTklluQm5ikCANmXu+U3AAAA","action":"decompress"}}
```

Result:

```json
{"text":"na na na na na na na na na na na na na na na na Batman!","encoding":"utf-8","binary":false,"bytes":55}
```

**Why is the compressed result larger than my text?** Gzip adds 18 bytes of header and checksum, and base64 adds a third on top. Compression only pays off on longer or repetitive text.

**Is there a size limit?** Yes. Decompression stops with an error once the output passes 5 MB, which also protects against "zip bomb" data that expands enormously.

**What if the decompressed data is not text?** Bytes that are not valid UTF-8 are returned as base64, with "binary" set to true.
