DevToolsmith

Content-Length Header

The Content-Length request and response header gives the size of the body in bytes.

Type
Request and response header
Category
Content and negotiation
Defined in
RFC 9110

Syntax

Content-Length: <bytes>

How Content-Length works

Clients use it to show download progress and to know where the body ends on a reused connection. It counts bytes after compression, not characters: “é” is two bytes in UTF-8. Responses whose length isn’t known in advance use chunked transfer (HTTP/1.1) or simply end the stream (HTTP/2 and 3) instead.

Examples

A 3,495-byte body
Content-Length: 3495

Common mistakes

  • A Content-Length smaller than the real body truncates the response; a larger one makes clients hang waiting for the rest. Let your framework compute it.

Check it

curl -sI https://example.com | grep -i '^content-length:'

Paste a full set of response headers into the HTTP header checker to get every header explained and common mistakes flagged.

Related headers

  • Transfer-Encoding: says how the body is framed on an HTTP/1.1 connection; in practice, always chunked.
  • Content-Encoding: names the compression applied to the body, such as gzip, br (Brotli) or zstd.
  • Range: asks for only part of a resource, for resuming downloads and seeking in media.

More content and negotiation headers

Content-Type , Content-Disposition , Accept , Accept-Encoding , Accept-Language .

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What does the Content-Length header do?

The Content-Length request and response header gives the size of the body in bytes. Clients use it to show download progress and to know where the body ends on a reused connection. It counts bytes after compression, not characters: “é” is two bytes in UTF-8. Responses whose length isn’t known in advance use chunked transfer (HTTP/1.1) or simply end the stream (HTTP/2 and 3) instead.

How do I see the Content-Length header?

Run "curl -sI https://example.com" to print a response’s headers, or open the Network tab in your browser’s dev tools and select the request. Paste the headers into the HTTP header checker on this site to get each one explained.