# Deflate compress and decompress

Compress text to a zlib or raw deflate stream as base64, or decompress one. The format is detected.

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

## Inputs

- `text` (required, string): The text to compress, or base64 zlib or deflate data to decompress.
- `action` (optional, string, one of `compress`, `decompress`, default `"compress"`): Compress text, or decompress deflate data.
- `format` (optional, string, one of `zlib`, `raw`, default `"zlib"`): When compressing: "zlib" adds the two-byte header and checksum, "raw" is the bare deflate stream. Decompression detects the format itself.
- `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":"eJzLS1TIIwU5JZbkJuYpAgDl2hFl","bytes_before":55,"bytes_after":21,"ratio":0.382}
```

## Example 2: A raw deflate stream

```json
{"input":{"text":"na na na na na na na na na na na na na na na na Batman!","format":"raw"}}
```

Result:

```json
{"text":"y0tUyCMFOSWW5CbmKQIA","bytes_before":55,"bytes_after":15,"ratio":0.273}
```

## Example 3: The format is detected

```json
{"input":{"text":"eJzLS1TIIwU5JZbkJuYpAgDl2hFl","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,"format":"zlib"}
```

**What is the difference between zlib, raw deflate and gzip?** All three hold the same deflate-compressed data. Zlib wraps it in a 2-byte header and an Adler-32 checksum, gzip in a larger header and a CRC-32, and raw deflate has no wrapper at all.

**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.
