ua-parser-js
UAParser.js - The Essential Web Development Tool for User-Agent Detection. Detect Browsers, OS, Devices, Bots, Apps, AI Crawlers, and more. Run in Browser (client-side) or Node.js (server-side).
A JavaScript library that parses the user-agent string from any browser or HTTP request and tells you the browser name, OS, device type, CPU architecture, and whether the visitor is a bot or AI crawler.
UAParser.js is a JavaScript library that reads a user-agent string and tells you what browser, operating system, device type, and CPU architecture produced it. Every time someone visits a website, their browser sends a short text string identifying itself. This library parses that string and gives you structured information, such as whether the visitor is on Chrome 120 on Windows 11, or Safari on an iPhone, or a bot crawling for search indexing.
The library runs in two places: directly inside a web page so the browser can identify itself, or on a server running Node.js where you can check the user-agent of incoming requests. It also supports a newer mechanism called Client Hints, which is a more accurate alternative to the traditional user-agent string that some browsers have started sending instead.
There are two open-source editions and several paid ones. Version 1.x carries an MIT license and handles basic browser, OS, device, CPU, and rendering engine detection. Version 2.x switched to an AGPL license and adds higher accuracy, bot detection, AI crawler detection, and identification of apps, email clients, media players, and other non-browser software. The AGPL license means any product that uses v2.x must also open its own source code unless a commercial license is purchased. Paid tiers (PRO Personal, PRO Business, PRO Enterprise) remove that requirement and include one year of direct support.
For a project that needs to know whether a visitor is on mobile or desktop, whether a request is coming from a real person or an automated crawler, or which browser families to support, this library provides that information from a single function call. It is distributed through npm and available via CDN for direct browser use, and it has TypeScript type definitions included.
Where it fits
- Detect whether a website visitor is on a mobile or desktop device so you can serve an appropriate layout.
- Identify bot traffic and AI crawlers in your server logs to separate real users from automated requests.
- Check which browser and OS version a user is on to decide whether to show a compatibility warning.
- Build analytics dashboards that break down your traffic by browser family, OS, and device type.