Skip to main content
CheckTown
Dev Tools

User Agent Parsing: How to Read Browser and Device Information

Published 5 min read
In this article

What Is a User Agent String?

A user agent string is a text identifier that browsers and HTTP clients send with every request. It tells the server which browser, operating system, and device is making the request. For example, Chrome on Windows sends a string containing the browser version, the rendering engine, and the OS version.

User agent strings follow a loosely defined format that has grown more complex over time. Modern strings often contain compatibility tokens from older browsers, making them difficult to parse manually. A dedicated parser extracts structured data from this messy text.

How User Agent Parsing Works

A user agent parser breaks the raw string into structured components using pattern matching and known signature databases. The result is a clean object with browser, OS, device, and engine details.

  • Browser detection — identifies the browser name and version by matching known tokens like Chrome/, Firefox/, or Safari/
  • OS identification — extracts the operating system and version from platform tokens like Windows NT 10.0 or Mac OS X
  • Device classification — determines whether the client is a desktop, mobile, tablet, or bot based on device-specific markers

Try it free — no signup required

Parse a User Agent String →

When To Use User Agent Parsing

User agent data helps you understand your audience and adapt your application to different environments.

  • Analytics — track browser and OS distribution across your user base to prioritize testing and support
  • Responsive serving — serve optimized assets (images, scripts) based on the detected device type or browser capabilities
  • Bot detection — identify crawlers, scrapers, and automated tools by their user agent signatures to apply rate limiting or serve different content

Frequently Asked Questions

Can user agent strings be spoofed?

Yes. Any HTTP client can send any user agent string. Browser extensions and developer tools make spoofing trivial. For this reason, user agent data should be used for analytics and progressive enhancement, not for security or access control decisions.

What are Client Hints and do they replace user agents?

Client Hints (Sec-CH-UA headers) are a newer, structured alternative proposed by Chromium-based browsers. They provide browser, platform, and device data in separate headers. However, adoption is incomplete — Firefox and Safari have limited support — so user agent strings remain the universal fallback.

How do I detect mobile devices reliably?

The most reliable approach combines user agent parsing with feature detection. Parse the UA string for mobile keywords (Mobile, Android, iPhone) and also check screen size or touch support via JavaScript. Neither method alone is 100% accurate, but together they cover the vast majority of cases.

Related Tools