User-Agent Strings: How Parsing Works and Why It's Becoming Obsolete
Written by Toolsxulo Team · Last updated November 18, 2026
A User-Agent string looks like a single clean identifier, but it's actually a decades-deep pile of backward-compatibility tokens, where nearly every major browser claims to be several other browsers at once. That's not a bug in any individual browser - it's the accumulated result of decades of websites checking for specific substrings, and it's exactly why parsing one reliably requires an ordered set of pattern-matching rules rather than a simple lookup. This guide covers how these strings are actually structured, why detection is inherently probabilistic, and where the industry is heading instead.
Open the tool: User-Agent ParserThe layered, historically accumulated structure of a UA string
A typical modern User-Agent - something like Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 - packs in several independent pieces of information: a legacy compatibility token every browser still sends (Mozilla/5.0, a holdover from the 1990s browser wars that stuck around because so many old server-side scripts checked for it), an operating system and platform descriptor in the first parentheses, a rendering-engine token, and then one or more browser/version tokens. Critically, that string is read left to right but not evaluated that way - the tokens present don't map cleanly to "this browser, this engine, done." Chrome's string ends in Safari/537.36 even though it isn't Safari, because it inherited that token from WebKit, the engine Chrome originally forked before switching to its own Blink engine while keeping the legacy tokens intact for compatibility.
Why detecting the actual browser requires ordered, careful matching
Because Edge and Opera both build on Chromium and therefore both contain a genuine Chrome/ token in their UA string, and Safari's actual version lives in a separate Version/ token rather than in whatever browser name appears elsewhere, reliable detection has to check the more specific patterns - Edge, Opera, Samsung Internet - before falling through to a generic Chrome check, otherwise every Edge user gets misidentified as a Chrome user. The same layered-overlap problem applies to operating system detection: an iOS device's UA mentions "like Mac OS X" for compatibility reasons unrelated to actually running macOS, so OS detection patterns have to be similarly ordered and specific rather than doing a naive keyword search. None of this is a sign of a poorly written parser - it's an inherent property of a format with no strict specification and decades of accumulated compatibility cruft, so any parser is working from heuristics tuned against known real-world patterns, not a guaranteed-accurate identification.
Where User-Agent sniffing goes wrong, and what to use instead
The classic mistake is using UA sniffing for feature detection - branching application logic on "is this Safari" instead of directly checking whether the specific API or CSS feature the code needs is actually supported, which is both more accurate and immune to a browser changing its UA string or a user spoofing it. UA-based device-type detection (mobile vs. tablet vs. desktop) is similarly approximate, since it's inferring intent from string patterns like "Mobi" rather than reading an authoritative signal, and a browser's developer tools or an extension can override the sent UA at will, so it reflects only what a client currently claims to be. Treating a User-Agent as any kind of security or identity signal - for access control, bot-blocking, or anything with real stakes - is a mistake for the same reason: it's trivially spoofable and was never designed to be trustworthy in that sense.
The shift toward User-Agent Client Hints
Because the free-text User-Agent string is imprecise, bloated with legacy tokens, and increasingly frozen or reduced by browsers for privacy reasons (Chrome, for instance, has progressively stopped including granular OS version numbers in the default UA string it sends), the modern replacement is User-Agent Client Hints - a set of structured HTTP request headers (Sec-CH-UA, Sec-CH-UA-Platform, Sec-CH-UA-Mobile, and more) that a server explicitly requests and a browser answers with clean, unambiguous values instead of a single string to be parsed with regular expressions. Low-entropy hints like the browser's brand are sent by default, while higher-entropy ones like exact OS version require an explicit opt-in request from the server, giving users more control over what's disclosed. Client Hints aren't universally supported across every browser yet, which is why UA-string parsing - imperfect as it is - remains the practical fallback for the near term.
Reduction, and a second bot string
Chrome's reduction work froze a lot of the detail people used to scrape out of a desktop UA. A current string often carries a rounded Chrome token such as 126.0.0.0, still ends in Safari/537.36, and reports Windows NT 10.0 for both Windows 10 and Windows 11. The parser on this site therefore labels that OS 10/11 and does not invent a separate 64-bit field. The product token is Chrome. The Safari token is leftover compatibility.
A second bot string shows the other limit. Googlebot's smartphone UA is recognized, because the rules check Googlebot/ before Chrome/. The short classic Bingbot line — Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) — matches none of the browser, engine, or OS rules, so the cards read Unknown, Unknown, Unknown, and desktop. That is a gap in this rule list, not a broken paste. A fleet logger with a maintained bot catalog is a different product.
Frequently asked
- Why does Chrome's User-Agent string mention Safari and KHTML even though it's not Safari?
- Chrome's rendering engine, Blink, was originally forked from WebKit (Safari's engine), and KHTML was WebKit's own ancestor - Chrome kept those legacy tokens in its User-Agent purely for backward compatibility with older websites that checked for them to decide whether a browser could render modern pages. It's inherited history, not a claim about what Chrome actually is today.
- Are User-Agent Client Hints already a full replacement for the User-Agent string?
- Not yet universally - Client Hints are supported in Chromium-based browsers but not adopted the same way by every browser, and the classic User-Agent header hasn't been removed from any major browser, so both mechanisms currently coexist. Sites needing broad compatibility today still typically parse the User-Agent string while treating Client Hints as an enhancement where available.
- Can User-Agent detection reliably be used to block bots or scrapers?
- No, not by itself - a User-Agent string is just a value the client sends and can trivially set to whatever it wants, so any bot sophisticated enough to be a real concern will simply send a legitimate-looking browser UA. Genuine bot mitigation relies on behavioral signals, rate limiting, and other server-side heuristics, with User-Agent checks serving at most as a weak, easily bypassed first filter.
- Why do mobile and tablet detection sometimes misclassify a device?
- Device-type detection from a User-Agent string relies on substring patterns like "Mobi" or "Tablet," which manufacturers and browsers don't apply with perfect consistency - some large-screen Android tablets include "Mobile" in their UA, and some UAs can be spoofed or altered by privacy tools, browser extensions, or unusual configurations, all of which can produce a misclassification. It's a heuristic estimate, not a guaranteed-accurate hardware readout.