User Agent Strings Decoded
User Agent Strings Decoded
User-Agent strings are a mess of historical baggage. Understanding them helps with debugging, analytics, bot detection, and browser compatibility.
Anatomy of a User-Agent
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Why So Messy?
In the early web, servers sent different content to different browsers. Every new browser had to pretend to be all previous browsers to get full content. Chrome claims to be Mozilla, AppleWebKit, KHTML, Gecko, Chrome, AND Safari.
What You Can Extract
Parsing User-Agents
Don't use regex. Use a proper parser library:
// ua-parser-js
import UAParser from "ua-parser-js";
const ua = new UAParser(userAgentString);
console.log(ua.getBrowser()); // { name: "Chrome", version: "125.0.0.0" }
console.log(ua.getOS()); // { name: "macOS", version: "10.15.7" }
console.log(ua.getDevice()); // { type: undefined } (desktop)
Client Hints (The Future)
User-Agent Client Hints are the modern replacement. Instead of one giant string, the browser sends structured headers:
Sec-CH-UA: "Chrome";v="125", "Chromium";v="125"
Sec-CH-UA-Platform: "macOS"
Sec-CH-UA-Mobile: ?0
Servers request additional hints via Accept-CH header.
Common Bot User-Agents
| Bot | Pattern |
|-----|---------|
| Googlebot | Googlebot/2.1 |
| Bingbot | bingbot/2.0 |
| GPTBot | GPTBot/1.0 |
| ClaudeBot | ClaudeBot/1.0 |
Practical Uses
Try It
Use our User Agent Parser tool to paste any UA string and see the parsed browser, OS, device, and engine information.
Conclusion
User-Agent strings are legacy but still necessary. Use proper parsing libraries, consider Client Hints for new projects, and never rely on UA sniffing for feature detection when feature detection is possible.