Accept Header Explained

What the HTTP Accept header does and when it's used.

Published October 13, 2026

Accept is a request header listing the response media types the client can handle, with optional preference weights (q values).

How it works

It drives content negotiation: a server can answer JSON or HTML for the same URL.

The Accept header is part of the HTTP message and is case-insensitive in name.

In a real exchange

curl -i https://example.com/
Accept: application/json, text/html;q=0.8
Where Accept appears.

Practical examples

The header

Accept: application/json, text/html;q=0.8

Set or use it in code

curl -H 'Accept: application/json' https://api.example.com/users

Inspect it

curl -sI https://example.com | grep -i 'accept'

Common mistakes

  • Ignoring q weights
  • Returning HTML errors to API clients
  • Not sending Vary: Accept when caching

Key takeaways

  • Accept: Accept is a request header listing the response media types the client can handle, with optional preference weights (q values).
  • Check it in browser DevTools → Network.
  • Test with curl -I before deploying.

FAQ

What does q mean?

A weight from 0 to 1 expressing preference; higher is preferred.

Is Accept case sensitive?

Header names are case-insensitive; values may not be.

More HTTP articles