user agentuser agent parserbrowser detectiondevice detectionhttp headers

User Agent Strings Explained: How to Parse Browser and Device Information

User agent strings are cryptic but contain useful information. Learn what they contain, how to parse them, and when you actually need to.

8 min read

Related Tool

User Agent Parser

Open tool

Every browser sends a User-Agent header with every HTTP request. This string identifies the browser, its version, the operating system, the rendering engine, and sometimes the device type. User-agent strings are notoriously complex and sometimes deliberately misleading, but understanding them is useful for server-side analytics, debugging, and feature detection.

The Anatomy of a User Agent String

A typical desktop Chrome user agent looks like this: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36.

Breaking it down: Mozilla/5.0 is a historical compatibility token that every browser includes. The parenthesised section describes the platform: Windows NT 10.0 means Windows 10, Win64; x64 means a 64-bit system. AppleWebKit/537.36 is the rendering engine. KHTML, like Gecko is included for compatibility with servers that blocked non-Gecko browsers. Chrome/120.0.0.0 is the actual browser. Safari/537.36 is appended because Chrome is based on WebKit and servers that serve Safari-optimized content should serve it the same way to Chrome.

This historical accumulation of tokens is why user-agent strings look so verbose and redundant.

What You Can Reliably Detect

Browser family and version: Chrome, Firefox, Safari, Edge, Opera, and others can be identified with high confidence from their specific tokens.

Operating system and version: Windows, macOS, Linux, iOS, Android, and their major versions are detectable.

Device type: mobile and tablet user agents typically include keywords like Mobile or Tablet. Desktop agents do not. This is the basis for simple mobile detection.

What You Cannot Reliably Detect

Exact capabilities: a browser may claim to be any version or family by changing its user-agent string. Bot detection via user agents is unreliable because sophisticated bots use real browser user-agent strings.

Screen size: user agents contain no screen resolution information.

Using the DevHexLab User Agent Parser

Open the tool at /tools/developer/user-agent-parser. Paste a user-agent string. The tool extracts the browser name and version, operating system name and version, device type, and rendering engine in a clean table.

Frequently Asked Questions

Should I use user-agent detection for responsive design?

No. Use CSS media queries and the Responsive Design Mode in browser developer tools for layout decisions based on screen size. User-agent-based mobile detection is fragile.

What does "Mozilla/5.0" mean at the start of every user agent?

It is a legacy compatibility token. Netscape's browser was called Mozilla, and many early web servers served Netscape-only pages to browsers with Mozilla in their user agent. Every browser began including it to avoid being blocked. The number 5.0 is frozen and no longer reflects any real version.

Parse user agents for analytics and debugging, not for feature gates.