Guide
Reading a User-Agent string
By Logappradeep · ServiceNow developer
Every HTTP request your browser makes includes a User-Agent header, a line of text that identifies the software making the request. Servers, analytics tools and logs use it to work out which browser, operating system and device a visitor is on. Reading one by eye is harder than it should be, because the format carries decades of historical baggage.
Why User-Agent strings look so odd
Here is a typical desktop Chrome string:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Almost none of it is literally true. Mozilla/5.0 dates from the 1990s, when sites served better pages to Netscape and every other browser started claiming to be Mozilla. AppleWebKit and KHTML, like Gecko describe engine ancestry. Safari/537.36 is there so sites that look for Safari keep working. The tokens that really identify this browser are Chrome/120 and the platform Windows NT 10.0; Win64; x64.
How this parser works
The tool reads your browser's own string from navigator.userAgent when the page opens, and you can replace it with any string, for example one copied from a server log. It matches known product tokens to identify the browser family and version, looks for platform markers such as Windows NT, Mac OS X, iPhone OS, Android and Linux to find the operating system, and checks for markers like Mobile, iPhone, iPad and Android to classify the device as desktop or mobile/tablet. Parsing happens locally; the string is not sent anywhere.
Common uses
- Making sense of User-Agent values in access logs and error reports.
- Checking what a mobile device or embedded web view reports about itself.
- Testing server-side code that branches on the User-Agent.
- Including accurate environment details in a bug report.
Pitfalls
Tokens overlap. Edge, Opera, Brave, Samsung Internet and other Chromium-based browsers all include Chrome/ and Safari/. Edge adds Edg/ and Opera adds OPR/, so a parser must check those specific tokens before the generic ones or it will report every Chromium browser as Chrome. Chrome itself includes Safari/, so Safari detection must rule Chrome out.
Frozen and reduced values. To limit fingerprinting, browsers now report less. Chrome reports a fixed minor version such as 120.0.0.0, Windows 11 still reports Windows NT 10.0, and Safari and Chrome on macOS report Mac OS X 10_15_7 regardless of the actual version. iPads request desktop sites by default and present themselves as a Mac.
Anyone can change it. Bots, scripts and browser extensions can send any User-Agent they like, so never use it for security decisions. For richer and more reliable data, Chromium browsers support User-Agent Client Hints through headers like Sec-CH-UA. For front-end behavior, feature detection, such as checking whether an API exists, beats User-Agent sniffing every time.