Skip to content

Why UAParser.js? ​

Trusted for a Generation of the Web. Built for What’s Next. ​

UAParser.js has been around the block. It is trusted in production, actively maintained, and completely open for anyone to inspect:

  • Battle-tested at scale: More than 100M+ npm downloads every month.
  • Stay cutting-edge: 14+ years of continuous maintenance keeps detection with new browsers, devices, platforms, bots, apps, etc.
  • Open by default: The source code, detection rules, release history, and issue tracker are all available on GitHub🡥, with over 10K+ stars.
  • Seriously tested and secured: Unit, type, lint, browser, and fuzz tests help catch problems early, including ReDoS vulnerabilities.
  • Used by familiar names: Found in public projects from Microsoft, Amazon, Meta, Shopify, Slack, Discord, and more (see the showcase🡥).
  • No dependency baggage: The core stays small and dependency-free, so there is less to download, audit, and worry about.

"A great utility library to have when you're investigating what kind of users are visiting your website and how you can improve their UX. Supports most browsers out there." —Gabrijel Golubić

"For years, it has been appreciated as a valuable tool for web developers. Its ability to accurately parse user agent strings... has made it an essential library for many of us." —LogRocket

Real-World User-Agents Are Full of Surprises ​

Parsing user-agents looks simple... until you actually try it. Every different browsers, devices, and apps each have their own quirks, and they really love to surprise you.

Let's run through a quick example. Suppose we receive this user-agent from a visitor:

problem.js
js
const ua = `Mozilla/5.0 (Linux; Android 10; STK-LX1 Build/HONORSTK-LX1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/110.0.5481.153 Mobile Safari/537.36 musical_ly_2022803040 JsSdk/1.0 NetType/WIFI Channel/huaweiadsglobal_int AppName/musical_ly app_version/28.3.4 ByteLocale/en ByteFullLocale/en Region/IQ Spark/1.2.7-alpha.8 AppVersion/28.3.4 PIA/1.5.11 BytedanceWebview/d8a21c6`;

Yep, this is a real user-agent (what???), and it shows up more often than you'd think. But hey, no worries, let's just use UAParser.js:

solution.js
js
// Just pass that complex user-agent string to UAParser
const parser = new UAParser(ua);

// And voila!

console.log(parser.getBrowser());
/* 
    {    
        name : "TikTok", 
        version : "28.3.4", 
        major : "28", 
        type: "inapp"
    }
*/

console.log(parser.getEngine());
/*
    {
        name : "Blink", 
        version : "110.0.5481.153"
    }
*/

console.log(parser.getDevice());
/*
    {
        type : "mobile", 
        vendor : "Honor", 
        model : "STK-LX1" 
    }
*/

console.log(parser.getOS());
/*
    { 
        name : "Android", 
        version : "10" 
    }
*/

So, in summary, our visitor is browsing from a TikTok app on an Honor device running Android 10.

Phew! Thanks, UAParser.js!

In Summary: UAParser.js Turns Chaos Into Schema ​

UAParser.js simplifies user-agent detection by providing a structured approach. It's a clean and reliable alternative to the messy reality of real-world user-agent strings.

Say no more to complicated user-agent strings. UAParser.js automagically turns them into well-structured data:

Illustration

UAParser.js v2 is licensed under AGPLv3 or PRO licenses.