Accept

The HTTP Accept request header indicates the media types a client prefers to receive from the server.

Usage

The Accept header drives content negotiation. A client sends a list of media types ranked by preference, and the server selects the best match from the representations available for the requested resource.

Browsers set this header automatically based on the request context. A navigation request typically asks for text/html, while an image element asks for common image formats. API clients often send application/json or application/xml.

When the server has no representation matching any listed type, the expected response is 406 Not Acceptable. In practice, many servers ignore the header and return the default representation instead.

Directives

media-type/subtype

A specific media type such as text/html or application/json. The server treats the full type/subtype pair as a concrete preference.

media-type/*

A wildcard subtype. image/* signals acceptance of any image format, whether image/png, image/webp, or image/avif.

\*/\*

Accepts any media type. This wildcard acts as a fallback when no other type matches.

;q= (quality value)

A weight between 0 and 1 expressing relative preference. Higher values indicate stronger preference. When omitted, the default weight is 1.0. A value of 0 means the type is not acceptable.

Example

A browser requesting an HTML page sends several media types ranked by quality value. The highest-weighted type the server supports wins.

Accept: text/html, application/xhtml+xml, */*;q=0.8

An API client requesting JSON with an XML fallback assigns a lower quality value to XML.

Accept: application/json, application/xml;q=0.9

An AI agent requesting a page in Markdown to reduce token consumption, with an HTML fallback.

Accept: text/markdown, text/html;q=0.9

AI agents and content negotiation

CDN providers like Cloudflare convert HTML pages to Markdown on the fly when a request includes Accept: text/markdown. The conversion reduces token count by up to 80%, making content negotiation a practical optimization for LLM-based agents and crawlers.

An API client requesting structured error responses uses application/problem+json alongside the regular content type. The server returns problem details for errors and JSON for successful responses.

Accept: application/problem+json, application/json

A request listing multiple text formats with explicit priorities. text/html carries the default weight of 1.0, text/plain follows at 0.9, any other text format at 0.8, and everything else at 0.7.

Accept: text/html, text/plain;q=0.9, text/*;q=0.8, */*;q=0.7

Note

When two types share the same quality value, the more specific type takes precedence. If both text/html and text/* carry a weight of 1.0, the server selects text/html.

Takeaway

The Accept header tells the server which media types the client prefers, enabling content negotiation so the server returns the most appropriate representation.

See also

Last updated: March 11, 2026