# Compression Algorithm Comparison (gzip vs brotli vs deflate)

> Compression Algorithm Comparison (gzip vs brotli vs deflate) is a paid API for AI agents from agent402.tools, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-14).

Runs input content through gzip, brotli, and raw deflate at maximum compression settings and returns the output size and compression ratio for each algorithm.

## Facts

- Endpoint: POST https://agent402.tools/api/compress-compare
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/compression-algorithm-comparison-gzip-vs-brotli-vs-deflate-c516083b
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_YhDqT2EK6_FcJ8hpIV2ng

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability compression-algorithm-comparison-gzip-vs-brotli-vs-deflate-c516083b -d '<json body>'
```

Example prompt: I want to pick the best compression algorithm for my API response payload — can you run this JSON string through gzip, brotli, and deflate at max settings and tell me the output size and ratio for each: '{"users":[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]}'?

## When to prefer this

Use this endpoint when you need to make an informed decision about which compression algorithm to deploy for a specific content type. It is especially valuable before committing to a compression strategy in production, since optimal algorithm choice is highly content-dependent (text compresses well, binary often does not). Prefer this over running individual compression endpoints when you want a side-by-side comparison in a single call.

## Known failure modes

- Input exceeds 10MB limit after decoding — request rejected
- Invalid inputFormat value (must be utf8, base64, or hex) — bad request error
- Malformed base64 or hex encoding when non-utf8 format is specified
- Payment not provided or insufficient — 402 Payment Required
- Empty input string — may return trivial results or error

## How this service works

Run the same input through gzip, brotli, and raw deflate at max settings and report each one's output size and ratio. Use this to decide which algorithm to actually use - the answer depends on your content (binary often resists compression entirely; English prose squeezes well with brotli; JSON sits in between).

## Output

Returns the compressed output size in bytes and the compression ratio for each of the three algorithms (gzip, brotli, raw deflate), allowing comparison to determine which algorithm is most effective for the given input content.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "input": {
   "type": "string",
   "description": "Content to test (max 10MB after decoding)"
  },
  "inputFormat": {
   "type": "string",
   "description": "How `input` is encoded: utf8 (default), base64, or hex"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "best": "brotli",
  "results": [
   {
    "ratio": 0.6782,
    "algorithm": "brotli",
    "outputBytes": 28
   },
   {
    "ratio": 0.5287,
    "algorithm": "gzip",
    "outputBytes": 41
   },
   {
    "ratio": 0.6667,
    "algorithm": "deflate",
    "outputBytes": 29
   }
  ],
  "inputBytes": 87
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/compression-algorithm-comparison-gzip-vs-brotli-vs-deflate-c516083b/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
