Last updated
What Does the User Agent Parser Do?
The User Agent Parser analyzes user agent strings and extracts structured information: browser name and version, operating system, device type, and rendering engine. It handles the complex, historically inconsistent format of user agent strings accurately, giving you clean data from even the most convoluted strings.
Parsing a Chrome Desktop User Agent
Input:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.109 Safari/537.36
Parsed result:
Browser: Chrome 120.0.6099.109
Browser family: Chrome
Major version: 120
Engine: Blink (WebKit/537.36)
OS: Windows 11 (NT 10.0)
Architecture: 64-bit (Win64; x64)
Device type: Desktop
Mobile: No
Bot: No
Parsing a Mobile Safari User Agent
Input:
Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1
Parsed result:
Browser: Safari 17.2
Browser family: Mobile Safari
Engine: WebKit 605.1.15
OS: iOS 17.2
Device: iPhone
Device type: Mobile
Mobile: Yes
Tablet: No
Bot: No
Parsing a Firefox User Agent
Input:
Mozilla/5.0 (Macintosh; Intel Mac OS X 14.2; rv:121.0) Gecko/20100101 Firefox/121.0
Parsed result:
Browser: Firefox 121.0
Browser family: Firefox
Major version: 121
Engine: Gecko (rv:121.0)
OS: macOS 14.2 (Sonoma)
Architecture: Intel (x86_64)
Device type: Desktop
Mobile: No
Bot: No
Parsing an Android User Agent
Input:
Mozilla/5.0 (Linux; Android 14; SM-S911B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.144 Mobile Safari/537.36
Parsed result:
Browser: Chrome 120.0.6099.144
Browser family: Chrome Mobile
Engine: Blink
OS: Android 14
Device: Samsung Galaxy S23 (SM-S911B)
Manufacturer: Samsung
Device type: Mobile
Mobile: Yes
Bot: No
Parsing a Bot User Agent
Input:
Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
Parsed result:
Browser: Googlebot 2.1
Browser family: Googlebot
Bot: Yes ⚠
Bot type: Search engine crawler
Owner: Google
Info URL: http://www.google.com/bot.html
Device type: Bot
Mobile: No
---
Input:
Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)
Parsed result:
Browser: Bingbot 2.0
Bot: Yes ⚠
Owner: Microsoft Bing
Parsing an Edge User Agent
Input:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0
Parsed result:
Browser: Microsoft Edge 120.0.0.0
Browser family: Edge (Chromium-based)
Underlying: Chrome 120 (Blink engine)
Engine: Blink
OS: Windows 11
Device type: Desktop
Bot: No
Note: Edge includes Chrome tokens for backward compatibility.
The "Edg/" token (not "Edge/") identifies Chromium-based Edge.
Batch User Agent Parsing
Input (from server access log):
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ... Chrome/120.0.0.0 Safari/537.36
Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) ... Mobile/15E148 Safari/604.1
Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
Mozilla/5.0 (Linux; Android 14; Pixel 8) ... Chrome/120.0.6099.144 Mobile Safari/537.36
Mozilla/5.0 (Macintosh; Intel Mac OS X 14_2_1) ... Version/17.2 Safari/605.1.15
Parsed summary:
Browser Count %
Chrome 2 40%
Safari 1 20%
Mobile Safari 1 20%
Googlebot 1 20%
Device Type Count %
Desktop 2 40%
Mobile 2 40%
Bot 1 20%
OS Count %
Windows 1 20%
iOS 1 20%
Android 1 20%
macOS 1 20%
Bot 1 20%
Using Parsed Data in Code
// Node.js with ua-parser-js
import UAParser from 'ua-parser-js';
const ua = 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1';
const parser = new UAParser(ua);
const result = parser.getResult();
console.log(result.browser.name); // "Mobile Safari"
console.log(result.browser.version); // "17.2"
console.log(result.os.name); // "iOS"
console.log(result.os.version); // "17.2"
console.log(result.device.type); // "mobile"
console.log(result.device.model); // "iPhone"
// Python with user-agents library
from user_agents import parse
ua_string = 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X)...'
ua = parse(ua_string)
print(ua.browser.family) # Mobile Safari
print(ua.os.family) # iOS
print(ua.device.family) # iPhone
print(ua.is_mobile) # True
print(ua.is_bot) # False
Rendering Engine Reference
Engine Browsers Identifier in UA
------ -------- ----------------
Blink Chrome, Edge, Opera AppleWebKit/537.36 (KHTML, like Gecko)
WebKit Safari, iOS browsers AppleWebKit/605.1.15
Gecko Firefox Gecko/20100101
Trident IE (legacy) Trident/7.0; rv:11.0
Common Use Cases
- Analytics: understanding browser and device distribution of your audience
- Debugging: identifying browser-specific rendering issues from support tickets
- Security: detecting bot traffic and suspicious user agents in access logs
- Personalization: serving mobile-optimized content based on device type
- Testing: verifying that browser detection logic works correctly
- Log analysis: processing thousands of user agents from server access logs