Accept-Language
request headercontent
The user's preferred languages, in order, from their browser settings.
Browsers build Accept-Language from the user's language settings — for example en-GB,en;q=0.9,fr;q=0.8. Servers can use it to choose a default language on a first visit. It's a hint, not a command: let users switch, and remember their choice.
Syntax
Accept-Language: <language-tag>[;q=<weight>], …
Defined in RFC 9110 §12.5.4 — Accept-Language.
Examples
Accept-Language: en-GB,en;q=0.9,fr;q=0.8
British English, then any English, then French
Accept-Language: de-DE,de;q=0.9,en;q=0.8
German first, English as a fallback
Good to know
- Don't redirect on Accept-Language alone — someone on a borrowed or work computer gets the wrong language with no way out. Suggest a switch, and let a cookie or the URL override it.
- If one URL returns different languages, send
Vary: Accept-Language; separate URLs per language (/de/…) are better for search engines. - Googlebot usually crawls without Accept-Language, so content that depends on it may never be indexed.
- In the browser,
navigator.languagesgives JavaScript the same list.
How to set Accept-Language
await fetch("https://api.example.com/", {
headers: { "Accept-Language": "en-GB,en;q=0.9,fr;q=0.8" },
});curl -H 'Accept-Language: en-GB,en;q=0.9,fr;q=0.8' https://api.example.com/
Check it
In the browser, open DevTools → Network, pick a request and look under Request Headers. From the command line, curl's verbose mode prints every header it sends, prefixed with >:
curl -sv https://example.com/ -o /dev/null 2>&1 | grep '^>'
Frequently asked questions
What does q=0.9 mean?
It's a weight from 0 to 1 that ranks the languages; a language without q counts as 1. en-GB,en;q=0.9 means British English first, then any English.