What is a user agent string?
Definition A user agent is the software that acts for the user, usually the browser, and the user agent string is the text it sends in every HTTP request's User-Agent header (and exposes as navigator.userAgent) to identify itself: browser, version, rendering engine and operating system. Servers use it for statistics and sometimes to serve mobile pages, but it is unreliable for detection, and browsers now reduce the detail it contains.
Related guide: Responsive Breakpoints in 2026: Which Widths to Design For
What does a user agent string look like?
Chrome on an Android phone sends something like:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/141.0.0.0 Mobile Safari/537.36
Safari on iPhone:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15
(KHTML, like Gecko) Version/18.6 Mobile/15E148 Safari/604.1
The strings are full of history: "Mozilla/5.0", "KHTML, like Gecko" and "Safari" appear in almost every browser's string because sites once sniffed for them. The useful parts are the platform (iPhone, Android), the word Mobile and the browser token. Chrome on iPhone adds CriOS, Firefox on iPhone FxiOS.
Why user agent detection is unreliable
- Reduced strings. Chrome now sends a frozen Android version ("Android 10") and model ("K") and only the major version, to limit fingerprinting.
- iPads look like Macs. Since iPadOS 13, Safari on iPad requests desktop sites by default and reports itself as a Mac.
- Same engine, different names. Almost every iPhone browser renders with WebKit, whatever its name says.
- Spoofing. Any client can send any string, and DevTools device mode changes it with one click.
For layout, use media queries and responsive design; for features, use @supports or feature detection in JavaScript. Chromium browsers also offer User-Agent Client Hints (Sec-CH-UA-Mobile, navigator.userAgentData), a structured replacement that Safari and Firefox don't support.
Example
// Prefer capabilities over UA strings
const touch = matchMedia('(pointer: coarse)').matches;
const narrow = matchMedia('(max-width: 600px)').matches;
On iPhone vs Android
Both platforms have a "Request Desktop Website" (Safari) or "Desktop site" (Chrome) option. It sends a desktop user agent and, in Chrome on Android, lays the page out in a wide desktop viewport too, so a visitor may see your desktop version on a phone. On iPhone, every browser's string still contains AppleWebKit and Mobile/, so CriOS is the only sign that a visitor is using Chrome rather than Safari.
User agents in MobileCheck
MobileCheck loads each device with its real user agent string together with its viewport, pixel ratio and touch support, so sites that serve different HTML to phones show their real mobile version in the report.
Related terms
Guides and tools
- Responsive Breakpoints in 2026: Which Widths to Design For
- What is my viewport
- Test a website on iPhone