curl --compressed: Request a Compressed Response
--compressed asks for a smaller transfer and decodes it for you.
For large JSON responses or text artifacts, requesting compression cuts transfer time. curl handles the decoding automatically.
What it does
--compressed sets an Accept-Encoding header advertising the algorithms curl was built with (commonly gzip, deflate, and brotli), and transparently decompresses the response before writing it. You get the decoded body; you do not handle the compression yourself. If the server does not compress, you simply get the plain response.
Common usage
curl --compressed https://api.example.com/large.json
curl --compressed -o data.json https://api.example.com/large.json
curl -fsS --compressed -H "Authorization: Bearer $T" https://api.example.com/listFlags
| Flag | What it does |
|---|---|
| --compressed | Request and transparently decode compression |
| --compressed-ssh | Request compression for SCP/SFTP transfers |
| -H 'Accept-Encoding: gzip' | Manual header, but no auto-decoding |
| --tr-encoding | Request compressed transfer encoding |
In CI
Add --compressed to calls that return large text payloads to shave transfer time on metered or slow runner networks. Do not set Accept-Encoding manually unless you intend to decompress yourself, because curl will then hand you raw compressed bytes that downstream tools cannot read.
Common errors in CI
Garbled or binary-looking output from a JSON endpoint usually means you set -H 'Accept-Encoding: gzip' manually instead of --compressed, so curl did not decode it. Use --compressed to get the decoded body.