DevToolsmith

Accept Header

The Accept request header lists the response formats the client prefers, with optional weights.

Type
Request header
Category
Content and negotiation
Defined in
RFC 9110

Syntax

Accept: <type>/<subtype>[;q=<weight>], …

How Accept works

Servers use it for content negotiation, for example returning JSON to API clients and HTML to browsers from the same URL. q values from 0 to 1 rank alternatives. Browsers send a long default for navigation that prefers HTML, and advertise image formats such as AVIF and WebP on image requests.

Examples

An API client
Accept: application/json
Prefer JSON, accept anything
Accept: application/json, text/plain;q=0.9, */*;q=0.8

Common mistakes

  • If the server can’t produce any acceptable format it may answer 406 Not Acceptable, but most just send their default.

Check it

# Show the request headers curl sends (lines starting with >)
curl -sv -o /dev/null https://example.com 2>&1 | grep '^>'

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

Related headers

  • Content-Type: states the media type (MIME type) of the body, and for text, its character encoding.
  • Accept-Encoding: lists the compression formats the client can decode.
  • Accept-Language: lists the user’s preferred languages, from the browser or OS settings.
  • Vary: lists the request headers that change the response, so caches keep a separate copy for each value.

More content and negotiation headers

Content-Disposition , Content-Encoding , Content-Length , Range , Transfer-Encoding .

Sources

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

Frequently asked questions

What does the Accept header do?

The Accept request header lists the response formats the client prefers, with optional weights. Servers use it for content negotiation, for example returning JSON to API clients and HTML to browsers from the same URL. q values from 0 to 1 rank alternatives. Browsers send a long default for navigation that prefers HTML, and advertise image formats such as AVIF and WebP on image requests.

How do I see the Accept header?

Open your browser’s dev tools, select a request in the Network tab and look under Request Headers. On the command line, "curl -v https://example.com" prints the request headers it sends, marked with ">".