User-agent parser
Detect and parse Browser, Engine, OS, CPU, and Device type/model from an user-agent string.
Online User-Agent Parser: Device Detection, Browser Engines & Client Hints
1. Quick Overview & Core Advantages
The Online User-Agent Parser is a client-side diagnostic utility designed to inspect, parse, and analyze HTTP User-Agent strings and User-Agent Client Hints (UA-CH). It extracts device categories, operating system versions, rendering engines, browser release builds, and bot/crawler classifications.
Operating under a strict Zero-Knowledge Architecture: user-agent headers, hardware identifiers, and browser fingerprints never leave local browser memory. Parsing routines execute entirely within the local browser runtime using regex pattern matching. Internal system configurations, testing environments, and user devices remain completely private.
Core Technical Advantages
- Zero-Knowledge Privacy: User-Agent inspection runs locally in browser memory.
- Deep Device & OS Recognition: Identifies Windows, macOS, Linux, Android, iOS, iPadOS, ChromeOS, and embedded devices.
- Browser Engine Identification: Accurately maps Blink, Gecko, WebKit, and historical engines alongside browser brands (Chrome, Safari, Firefox, Edge, Opera, Brave).
- Bot & Web Crawler Detection: Recognizes common web spiders and crawlers (including Googlebot, Bingbot, Applebot, and SEO audit bots).
2. How to Use Step-by-Step Guide
Analyzing a User-Agent String
- Auto-Detect or Paste: Click Detect My Browser to inspect your current browser’s User-Agent string, or paste any custom User-Agent into the input box.
- Review Extracted Metrics: The parser evaluates the string and breaks down key attributes:
- Browser: Name, Major Version, Full Build Version
- Operating System: Platform Name, Version, Kernel Architecture (64-bit/ARM)
- Device: Category (Desktop, Mobile, Tablet, Smart TV, Bot)
- Rendering Engine: Engine Name and Version (Blink, WebKit, Gecko)
- Copy Parsed JSON: Export the structured device metadata for logging, feature flags, or analytics configurations.
Sample Parsing Breakdown:
Raw: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Parsed Breakdown:
Browser: Chrome (Version 126.0.0.0)
Engine: Blink / AppleWebKit (537.36)
OS: macOS Catalina (10.15.7)
Device: Desktop (Apple Macintosh)
Bot Status: False (Human Client)
3. Algorithmic & Specification Deep Dive
The Structure of Modern User-Agent Strings
User-Agent strings contain historical compatibility tokens dating back to early browser developments. For example, modern Chrome browsers include Mozilla/5.0, AppleWebKit/537.36, KHTML, and Safari/537.36 tokens to ensure compatibility with legacy web servers.
Mozilla/5.0 (Platform; Encryption; OS-Version) Engine/Version (KHTML, like Gecko) Browser/Version Safari/Version
The Transition to User-Agent Client Hints (UA-CH)
Due to privacy and browser-fingerprinting concerns, major browser vendors are freezing the traditional User-Agent string and transitioning to User-Agent Client Hints (W3C draft):
- Low-Entropy Hints (Sent by default):
Sec-CH-UA: Brand and major version (e.g.,"Google Chrome";v="126")Sec-CH-UA-Mobile: Boolean indicator for mobile devices (?0or?1)Sec-CH-UA-Platform: Operating system name (e.g.,"macOS")
- High-Entropy Hints (Requires explicit server
Accept-CHpermission):Sec-CH-UA-Model: Exact hardware modelSec-CH-UA-Platform-Version: Detailed OS version release
// Core User-Agent Parser Logic
export function parseUserAgent(ua: string) {
const isBot = /bot|googlebot|crawler|spider|robot|crawling/i.test(ua);
let browser = 'Unknown';
if (/Edg\//i.test(ua)) browser = 'Microsoft Edge';
else if (/Chrome\//i.test(ua)) browser = 'Google Chrome';
else if (/Safari\//i.test(ua) && !/Chrome/i.test(ua)) browser = 'Apple Safari';
else if (/Firefox\//i.test(ua)) browser = 'Mozilla Firefox';
let os = 'Unknown OS';
if (/Windows NT 10.0/i.test(ua)) os = 'Windows 10 / 11';
else if (/Mac OS X 10[._](\d+)/i.test(ua)) os = 'macOS';
else if (/Android/i.test(ua)) os = 'Android';
else if (/iPhone|iPad|iPod/i.test(ua)) os = 'iOS';
else if (/Linux/i.test(ua)) os = 'Linux';
return { browser, os, isBot };
}
4. Real-World Production & DevOps Use Cases
1. Responsive Asset & Feature Delivery
Web servers evaluate device classifications to deliver optimized image resolutions or conditionally load mobile-specific UI modules.
2. Traffic Auditing and Bot Traffic Analysis
Log analysis pipelines inspect User-Agent headers to distinguish legitimate user sessions from automated crawlers, scrapers, and malicious scanning tools.
5. Frequently Asked Questions (FAQs)
Why do most modern browsers include “Mozilla/5.0” in their User-Agent string?
During the early web browser era, websites often blocked browsers other than Netscape Navigator (code-named Mozilla). Competing browsers began prepending Mozilla/5.0 to ensure compatibility with existing server configurations.
What are User-Agent Client Hints, and how do they differ from User-Agent strings?
User-Agent Client Hints provide structured HTTP request headers (Sec-CH-UA-*) that share only basic browser information by default, requiring servers to explicitly request higher-entropy details (like specific device models) to better protect user privacy.
Can User-Agent strings be spoofed?
Yes. Clients can easily modify the User-Agent header using developer tools, browser extensions, or command-line tools like curl. User-Agent headers should never be used as a primary security check for authorization.
Is my device’s User-Agent string sent to any third party?
No. All string parsing and device evaluations execute locally within your browser runtime.
6. Security and Privacy Guarantee
- Local Client-Side Evaluation: Parsing runs strictly inside your local browser memory.
- Zero Device Fingerprint Retention: No hardware parameters or headers are stored or shared.
- W3C Standards Compliant: Compatible with both RFC User-Agent headers and User-Agent Client Hints.