# Content-Encoding Header — Syntax, Values & Examples

> Says how the body was compressed — gzip, Brotli or zstd — so the client can decompress it.

Servers compress text responses — HTML, CSS, JavaScript, JSON — to cut transfer size by 60–80%. The client lists what it supports in `Accept-Encoding`, and the server labels its choice with Content-Encoding. Browsers decompress transparently.

- Type: Response header
- Category: Content
- Defined in: [RFC 9110 §8.4 — Content-Encoding](https://www.rfc-editor.org/rfc/rfc9110.html#section-8.4)

## Syntax

```http
Content-Encoding: gzip | br | zstd | deflate
```

## Values

| Value | Meaning |
|---|---|
| `br` | Brotli — smaller than gzip for text, supported by every current browser |
| `gzip` | the universal fallback |
| `zstd` | Zstandard — fast, newer browser support |
| `deflate` | rarely used; inconsistent implementations |

## Examples

```http
Content-Encoding: br
```

a Brotli-compressed response

```http
Content-Encoding: gzip
```

a gzip-compressed response

## Good to know

- Don't compress images, video or zip files — they're already compressed.
- Compressed responses should carry `Vary: Accept-Encoding`; servers add it automatically.
- A doubly compressed body, or a header that doesn't match the bytes, shows up as garbled output or `ERR_CONTENT_DECODING_FAILED`.

## Who sets Content-Encoding

Web servers and CDNs pick and apply the encoding automatically (nginx `gzip on;`, Vercel and Cloudflare by default). Check what you get with `curl -sI -H "Accept-Encoding: br, gzip" https://example.com/ | grep -i content-encoding`.

## Check it

Fetch only the response headers and filter for Content-Encoding. In the browser, it's under Response Headers in DevTools → Network.

```sh
curl -sI https://example.com/ | grep -i '^content-encoding:'
```

## FAQ

### Why doesn't curl show Content-Encoding?

curl doesn't ask for compression unless you send Accept-Encoding (or use --compressed), so servers reply uncompressed.

## Related headers

- [Accept-Encoding](https://www.devkult.com/headers/accept-encoding.md): Lists the compression formats the client can decompress, so the server can pick one.
- [Vary](https://www.devkult.com/headers/vary.md): Lists the request headers that change the response, so caches keep a separate copy for each variant.
- [Content-Length](https://www.devkult.com/headers/content-length.md): The size of the message body in bytes.

Open the interactive page: https://www.devkult.com/headers/content-encoding