Skip to main content
Developer Tools September 3, 2026 · 6 min read

What Is a User Agent String and How to Parse It

Every HTTP request your browser sends includes a User-Agent header — a long, cryptic string that identifies the browser, engine, operating system, and sometimes the device. Understanding it helps with debugging, analytics, and compatibility decisions.

Anatomy of a User Agent String

A typical Chrome user agent looks something like:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

This string contains multiple tokens, each with a history:

  • Mozilla/5.0: A legacy compatibility token. Every browser includes this so servers don't block them.
  • Platform info: Operating system and architecture (Windows NT 10.0, Macintosh, Linux, Android, iPhone)
  • Engine: AppleWebKit, Gecko, or Blink — the rendering engine
  • Browser: Chrome, Firefox, Safari, Edge — with version numbers

Why User Agent Strings Are a Mess

User agent strings grew into their current chaos because of a decades-long history of browser sniffing. When Netscape was the dominant browser, servers sent better content to "Mozilla" clients. So Internet Explorer added "Mozilla" to its user agent. Then every new browser copied the same trick.

The result: Chrome's user agent claims to be Mozilla, AppleWebKit, KHTML, Gecko, Chrome, and Safari all at once. It's technically accurate in terms of compatibility, but absurd as an identifier.

What You Can Extract

Despite the messiness, a user agent parser can reliably extract:

Browser

Chrome 120, Firefox 121, Safari 17, Edge 120

Operating System

Windows 11, macOS 14, Ubuntu, Android 14, iOS 17

Device Type

Desktop, Mobile, Tablet

Bot Detection

Googlebot, Bingbot, ChatGPT-User, curl

User-Agent Client Hints: The Modern Replacement

Chromium-based browsers are moving to User-Agent Client Hints (UA-CH), a structured alternative that provides clean, granular data instead of one unstructured string.

With Client Hints, the server requests specific information it needs — browser brand, platform, mobile status — and gets clean, typed responses. This is more privacy-friendly (less fingerprinting surface) and easier to parse.

However, Client Hints are only available in Chromium browsers and require server-side opt-in via the Accept-CH header. The traditional User-Agent string remains the universal fallback.

When to Use User Agent Detection

  • Analytics: Understanding your audience's browsers, devices, and operating systems
  • Bug reports: Knowing the exact browser and OS when a user reports an issue
  • Bot detection: Identifying crawlers and automated tools in your access logs
  • Content delivery: Serving WebP images to browsers that support them, or mobile-optimised pages to phone browsers

For feature detection (does this browser support CSS Grid?), prefer JavaScript feature detection over user agent sniffing. User agent parsing is best for analytics and diagnostics, not for deciding what code to run.

Parse any user agent string

Paste a user agent and see the browser, OS, device, and bot status extracted instantly.

Open User Agent Parser