πŸ”

User Agent Parser

Parse user agent strings to extract browser, operating system, device, and engine information. Essential for web analytics, device detection, and browser compatibility testing.

Developer Tools
Loading tool...

How to Use User Agent Parser

Quick Start Guide

  1. Paste User Agent: Copy a user agent string into the input area
  2. Auto-Detect: Or check "Use Current Browser" to analyze your own browser
  3. View Results: See parsed browser, OS, device, and engine information
  4. Try Examples: Click example buttons to see different user agent types
  5. Copy Data: Copy the user agent string or parsed JSON data

What is a User Agent?

A user agent (UA) is a string that web browsers and other applications send to web servers to identify themselves. It contains information about the browser, operating system, device, and rendering engine.

Purpose: Device detection, analytics, browser compatibility Format: Text string with browser and system information Usage: Web analytics, responsive design, feature detection Location: HTTP request headers (User-Agent header)

Why Parse User Agents?

Analytics & Tracking:

  • Track which browsers visit your site
  • Monitor mobile vs desktop traffic
  • Identify popular operating systems
  • Detect bot and crawler traffic
  • Analyze browser version distribution

Development & Testing:

  • Debug browser-specific issues
  • Test responsive designs
  • Implement feature detection
  • Serve different content per device
  • Provide browser-specific fallbacks

Security & Monitoring:

  • Detect suspicious bots
  • Block malicious crawlers
  • Monitor unusual traffic patterns
  • Identify outdated browsers
  • Track attack vectors

User Agent Structure

Typical format:

Mozilla/5.0 (Platform) AppleWebKit/Version (KHTML, like Gecko) Browser/Version

Example breakdown:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Components:

  • Mozilla/5.0: Historic compatibility token
  • Windows NT 10.0: Operating system (Windows 10)
  • Win64; x64: CPU architecture (64-bit)
  • AppleWebKit/537.36: Rendering engine
  • Chrome/120.0.0.0: Browser name and version
  • Safari/537.36: Compatibility token

Parsed Information

This parser extracts:

Browser:

  • Name (Chrome, Firefox, Safari, Edge, Opera)
  • Full version number (120.0.0.0)
  • Major version (120)

Operating System:

  • Name (Windows, macOS, iOS, Android, Linux)
  • Version number (10, 17.1, etc.)

Device:

  • Type (desktop, mobile, tablet)
  • Vendor (Apple, Samsung, Google)
  • Model (iPhone, Pixel 7, iPad)

Engine:

  • Name (WebKit, Gecko, Blink, Trident)
  • Version number

CPU:

  • Architecture (amd64, arm64, ia32)

Bot Detection:

  • Identifies search engine crawlers
  • Detects social media bots
  • Flags automated tools

Common Use Cases

1. Detecting Mobile Devices

Purpose: Identify mobile visitors for responsive design

Example UA (iPhone):

Mozilla/5.0 (iPhone; CPU iPhone OS 17_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1

Parsed:

  • Device Type: mobile
  • Vendor: Apple
  • Model: iPhone
  • OS: iOS 17.1.1
  • Browser: Safari 17.1

Use case: Serve mobile-optimized content, redirect to mobile site, adjust layout.

2. Browser Version Detection

Purpose: Check if browser supports modern features

Example UA (Chrome):

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Parsed:

  • Browser: Chrome
  • Version: 120.0.0.0
  • Major: 120

Use case: Show upgrade notice for old browsers, enable modern features, provide fallbacks.

3. Operating System Analytics

Purpose: Track OS distribution of visitors

Example UA (macOS):

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15

Parsed:

  • OS: macOS
  • Version: 10.15.7
  • Browser: Safari 17.1

Use case: Analytics dashboards, OS-specific instructions, compatibility testing.

4. Bot Detection

Purpose: Identify search engine crawlers and bots

Example UA (Googlebot):

Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

Parsed:

  • Bot: Yes (detected)
  • Browser: Unknown (bot)
  • Purpose: Search engine crawler

Use case: Serve different content to bots, block malicious crawlers, analytics filtering.

5. Tablet Detection

Purpose: Differentiate tablets from phones and desktops

Example UA (iPad):

Mozilla/5.0 (iPad; CPU OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1

Parsed:

  • Device Type: tablet
  • Vendor: Apple
  • Model: iPad
  • OS: iOS 17.1

Use case: Tablet-optimized layouts, app download prompts, touch-friendly interfaces.

6. Debugging Browser Issues

Purpose: Identify specific browser/OS combination causing bugs

Example: User reports issue, provides UA:

Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0

Parsed:

  • Browser: Firefox 121
  • OS: Windows 7
  • Architecture: 64-bit

Use case: Reproduce bugs, test in specific environments, provide targeted fixes.

Features

Core Functionality

  • Browser Detection: Chrome, Firefox, Safari, Edge, Opera
  • OS Detection: Windows, macOS, iOS, Android, Linux
  • Device Type: Desktop, mobile, tablet
  • Engine Parsing: WebKit, Gecko, Blink, Trident
  • Bot Detection: Search engines, social media bots
  • Version Extraction: Full and major version numbers

Supported Browsers

  • Google Chrome / Chromium
  • Mozilla Firefox
  • Apple Safari
  • Microsoft Edge
  • Opera / Opera Mini
  • Internet Explorer (legacy)
  • Mobile browsers (Chrome Mobile, Safari Mobile)

Supported Operating Systems

  • Windows (7, 8, 8.1, 10, 11)
  • macOS (10.x, 11.x, 12.x, 13.x, 14.x)
  • iOS / iPadOS
  • Android
  • Linux distributions
  • Chrome OS

Device Detection

  • Smartphones (iPhone, Android phones)
  • Tablets (iPad, Android tablets)
  • Desktop computers
  • Vendor identification (Apple, Samsung, Google, etc.)
  • Model extraction where available

Bot Detection

Identifies:

  • Search engine crawlers (Googlebot, Bingbot, etc.)
  • Social media bots (Facebook, Twitter, LinkedIn)
  • Monitoring services
  • Automated tools
  • Web scrapers

Best Practices

1. Use Feature Detection Over UA Sniffing

Prefer:

if ('geolocation' in navigator) {
  // Use geolocation
}

Avoid:

if (userAgent.includes('Chrome')) {
  // Assume Chrome has geolocation
}

Why: Feature detection is more reliable. User agents can be spoofed or outdated.

2. Combine with Analytics

Use UA parsing for:

  • Traffic analysis
  • Browser statistics
  • Device breakdown
  • Bot filtering

Don't rely solely on UA for:

  • Security decisions
  • Feature availability
  • Critical functionality

3. Cache Parsed Results

Good:

const parsedUA = parseUserAgent(navigator.userAgent);
// Store in variable, use multiple times

Inefficient:

// Parsing repeatedly
parseUserAgent(navigator.userAgent).browser.name
parseUserAgent(navigator.userAgent).os.name

4. Handle Unknown Values

Always check:

const browser = parsed.browser.name || 'Unknown';
const version = parsed.browser.version || 'N/A';

Reason: Not all user agents contain complete information.

5. Update Parsing Logic Regularly

User agents change:

  • New browser versions
  • New devices
  • Updated OS versions
  • New UA formats

Solution: Use maintained libraries in production, update parsing patterns regularly.

Technical Details

How User Agent Parsing Works

1. Receive UA string from HTTP header or navigator.userAgent
2. Apply regex patterns to identify browser
3. Extract version numbers using pattern matching
4. Detect operating system from platform indicators
5. Identify device type from mobile/tablet keywords
6. Extract rendering engine information
7. Determine CPU architecture from system info
8. Check against bot patterns for crawler detection
9. Return structured data object

Parsing Patterns

Browser detection:

  • Chrome: /Chrome\/([\d.]+)/
  • Firefox: /Firefox\/([\d.]+)/
  • Safari: /Version\/([\d.]+)/
  • Edge: /Edg\/([\d.]+)/

OS detection:

  • Windows: /Windows NT ([\d.]+)/
  • macOS: /Mac OS X ([\d_]+)/
  • iOS: /OS ([\d_]+)/
  • Android: /Android ([\d.]+)/

Device detection:

  • Mobile: /Mobile|iPhone/
  • Tablet: /iPad|Tablet/
  • Desktop: everything else

Limitations

This is a basic parser:

  • Regex-based pattern matching
  • Limited to common browsers/OS
  • May not detect all devices
  • Simplified bot detection
  • No user agent validation

For production analytics:

  • ua-parser-js: Comprehensive UA library
  • bowser: Lightweight browser detection
  • platform.js: Detailed platform info
  • Google Analytics: Built-in UA parsing

User agents can be:

  • Spoofed or faked
  • Incomplete or malformed
  • Custom from apps/tools
  • Modified by proxies

Browser Compatibility

Works in all browsers that support JavaScript ES6+:

  • βœ… Chrome 90+
  • βœ… Firefox 88+
  • βœ… Safari 14+
  • βœ… Edge 90+
  • βœ… Opera 76+

Auto-detection requires:

  • Browser environment (not Node.js)
  • Access to navigator.userAgent

Privacy & Security

Client-Side Processing

  • 100% Local: All parsing in your browser
  • No Uploads: UA strings never sent to server
  • No Storage: Nothing saved or cached
  • No Tracking: No analytics on your UA
  • No Accounts: No login required

Privacy Notes

User agents reveal:

  • Browser and version
  • Operating system
  • Device type
  • General location indicators (language)

User agents do NOT reveal:

  • Personal information
  • Exact location
  • Browsing history
  • Installed extensions
  • Specific user identity

For privacy:

  • Some browsers send simplified UAs
  • Brave/Firefox offer UA protection
  • VPNs may modify UAs
  • Privacy extensions can spoof UAs

Common Patterns

Web Analytics

const ua = navigator.userAgent;
const parsed = parseUserAgent(ua);

trackAnalytics({
  browser: parsed.browser.name,
  browserVersion: parsed.browser.major,
  os: parsed.os.name,
  deviceType: parsed.device.type,
  isBot: parsed.isBot
});

Responsive Design

const parsed = parseUserAgent(navigator.userAgent);

if (parsed.device.type === 'mobile') {
  // Load mobile stylesheet
  loadMobileCSS();
} else if (parsed.device.type === 'tablet') {
  // Load tablet layout
  loadTabletLayout();
}

Browser Compatibility

const parsed = parseUserAgent(navigator.userAgent);

if (parsed.browser.name === 'Chrome' && parseInt(parsed.browser.major) < 90) {
  showUpgradeBanner();
}

Bot Filtering

const parsed = parseUserAgent(req.headers['user-agent']);

if (parsed.isBot) {
  // Serve static HTML for bots
  return renderStaticPage();
}

Integration Tips

Server-Side (Node.js)

// Express.js example
app.get('/', (req, res) => {
  const ua = req.headers['user-agent'];
  const parsed = parseUserAgent(ua);

  if (parsed.device.type === 'mobile') {
    res.redirect('/mobile');
  } else {
    res.render('desktop');
  }
});

Analytics Tracking

// Track device types
const parsed = parseUserAgent(navigator.userAgent);

gtag('event', 'page_view', {
  device_type: parsed.device.type,
  browser: parsed.browser.name,
  os: parsed.os.name
});

A/B Testing

// Serve different variants by browser
const parsed = parseUserAgent(navigator.userAgent);

if (parsed.browser.name === 'Safari') {
  showVariantA();
} else {
  showVariantB();
}

Note: For production use with comprehensive UA parsing, consider using established libraries like ua-parser-js or bowser. This tool is perfect for quick analysis, debugging, learning about user agents, and privacy-focused parsing.

Frequently Asked Questions

Related Utility Tools

Share Your Feedback

Help us improve this tool by sharing your experience

We will only use this to follow up on your feedback