Parse a user-agent string

Read a user-agent string into browser, engine, operating system and device type, with the caveats browsers have built in.

Parse a user-agent string

0 characters

Three steps — nothing to install

  1. Paste a user-agent string

    From a log line, a support ticket, or this browser's own header.

  2. Read the fields

    Browser and version, rendering engine, operating system and device class.

  3. Check the caveats

    The string is a hint, not a fact, and the page says where it lies.

Why user agents lie now

The string was designed to be read by servers that needed to send different markup. It grew into a compatibility mess: every browser pretends to be every other one so old sniffing code does not break. Chrome's string says Safari and WebKit; Edge's says Chrome and Safari; everything claims to be Mozilla.

In 2020 browsers began freezing the string. Chrome now reports a fixed minor version and a major version that only changes at milestones, and Safari reports the OS version as its own. So a version from this string can be right about the platform and wrong about the browser, which is why parsing rules must read the most specific token first.

Client Hints and what to use instead

Client Hints are the replacement: the server asks for the information it needs with response headers, and the browser sends structured values instead of a string to be guessed at. That is better for privacy, because the server gets only what it asks for, and better for accuracy, because the values are not spoofed for compatibility.

In a browser, feature detection beats both. Check whether the API you need exists rather than inferring it from a version number. Parsing a user agent is still necessary for analytics and for reading logs after the fact, which is what this page is for.

Reading the result

This parser checks for Edge, Opera, Samsung Internet, Firefox, Chrome and Safari in that order, because the more specific names appear inside the less specific ones. The engine comes from the Gecko, AppleWebKit and Chrome tokens, and the operating system from the platform token, with the version where one is present.

Device type is a rough guess from Mobi, iPad and Tablet: a string can be a phone, a tablet, a desktop browser or a crawler, and the boundary between a large phone and a small tablet is not in the string at all. Treat the answer as a starting point for a support question, not as a fact to act on in code.

Frequently asked questions

Is my string uploaded?No. It is parsed with regular expressions in this tab.
Why does Chrome report version 0.0.0?Browsers freeze the minor version in the user agent. Use Client Hints or feature detection for the real version.
Can it detect crawlers?It flags the common bot and crawler tokens, but a crawler can claim to be a browser.
Why is Safari's version the OS version?Safari's user agent reports the OS version, not the browser version. That is a historical quirk.
Can I parse a whole log file?Not here; this page parses one string. Use a script with the same rules for a file.
How accurate is the device type?It is a guess from a few tokens. Phones, tablets and desktops overlap and the string does not say which is which.