Reading a user-agent string, lie by lie
Here is the user-agent string Microsoft Edge sent on Windows in late 2024: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.2903.86. It names five products: Mozilla, AppleWebKit, Gecko, Chrome and Safari. Only one of them is the browser. Reading it piece by piece shows why parsing these strings is mostly about knowing which parts to ignore.
Mozilla/5.0 means nothing. Netscape was called Mozilla, sites once served their best pages only to it, and so every browser since has claimed to be Mozilla. The bracket comes next. Windows NT 10.0 is Windows 10, or Windows 11, which kept the same number, so the string cannot tell them apart. Win64 and x64 say it is a 64-bit build. AppleWebKit/537.36 and "KHTML, like Gecko" are inherited from Safari and frozen at those values; Edge does not run WebKit at all but Blink, Google’s fork of it. Chrome/131.0.0.0 is true in a sense: Edge is built on Chromium 131. The three zeros are deliberate, because Chromium browsers stopped sending their full version in this string. Safari/537.36 is another borrowed name.
The only part that is really Edge is the last token, Edg/131.0.2903.86. That is why a parser has to check in a careful order. If it looked for "Chrome" first, it would call Edge, Opera (OPR/) and Samsung Internet (SamsungBrowser/) all Chrome. If it looked for "Safari" first, it would call Chrome Safari. So the tool checks the rare, specific names first and the common, borrowed ones last. Paste the string above into the box and you get Microsoft Edge 131.0.2903.86 on the Blink engine, Windows 10 or 11, desktop.
Apple adds two more twists. On an iPhone, Chrome sends CriOS/ instead of Chrome/, and it runs on WebKit, not Blink, because Apple allows no other engine on iOS. Every iPhone browser renders pages like Safari, whatever it is called. And since iPadOS 13 an iPad asks for desktop sites by default, sending exactly the string a Mac sends, Intel Mac OS X 10_15_7 included. That version number is frozen too: Macs on macOS 14 and 15 still say 10.15.7. The way to spot the iPad is outside the string: it reports touch points, and a Mac has none. The second section of this page shows that for your own browser.
So be honest about what a user-agent string can do. It is good for reading logs, for spotting a crawler, and for a rough guess at the browser in a bug report. It is not proof of anything: any program can send any string, and curl or a scraper can pretend to be Chrome with one flag. Chromium browsers are moving the real detail into client hints (navigator.userAgentData and the Sec-CH-UA headers), which a site has to ask for. And for deciding what a page should do, testing whether the feature you need exists beats every user-agent check ever written.