Web & APIs · 4 min read
User-Agent Strings Explained (and Why They Lie)
Every HTTP request from a browser carries a User-Agent header describing the software that sent it. It looks like a jumble of names and version numbers — and it is, for historical reasons that explain a lot about the web.
Try it yourself with the related tool.
Parse a User-Agent →Advertisement
Anatomy of a User-Agent
A typical Chrome string is Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36. The part in brackets describes the platform. The rest is a list of rendering engines and browsers the browser claims compatibility with — only Chrome/130 is the real browser here.
Why everyone pretends to be Mozilla
In the 1990s, sites served advanced pages only to browsers that said "Mozilla". Each new browser added the names of its rivals so it would not get the downgraded version. The result is a string where Chrome claims to be Safari, Safari claims to be like Gecko, and Edge claims to be Chrome.
Reduced and unreliable
Browsers now freeze or reduce much of the string to limit fingerprinting — Chrome reports a fixed Windows version and a zeroed minor version, for example. Any client can also send whatever it likes, so bots routinely impersonate browsers. Treat the User-Agent as a hint for analytics and logs, never as a security check.
Better alternatives
To decide whether a feature works, use feature detection: check whether the API exists, or use CSS @supports. For more reliable device details, Chromium browsers offer User-Agent Client Hints through the Sec-CH-UA headers and navigator.userAgentData.
