explaingit

faisalman/ua-parser-js

10,118JavaScriptAudience · developerComplexity · 1/5LicenseSetup · easy

TLDR

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.

Mindmap

mindmap
  root((ua-parser-js))
    What it detects
      Browser name and version
      Operating system
      Device type
      CPU architecture
    Special detection
      Bots and crawlers
      AI crawlers
      Email clients
    Editions
      v1 MIT free
      v2 AGPL open-source
      PRO commercial
    Platforms
      Browser script
      Node.js server
      npm and CDN
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Detect whether a website visitor is on a mobile or desktop device so you can serve an appropriate layout.

USE CASE 2

Identify bot traffic and AI crawlers in your server logs to separate real users from automated requests.

USE CASE 3

Check which browser and OS version a user is on to decide whether to show a compatibility warning.

USE CASE 4

Build analytics dashboards that break down your traffic by browser family, OS, and device type.

Tech stack

JavaScriptTypeScriptNode.js

Getting it running

Difficulty · easy Time to first run · 5min

Version 2.x requires a commercial license for closed-source commercial products due to the AGPL license.

Version 1.x is MIT (use freely for anything). Version 2.x is AGPL, products using it must open-source their own code too, unless a commercial license is purchased.

In plain English

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.

Copy-paste prompts

Prompt 1
I want to use ua-parser-js in my Node.js server to detect whether each incoming request is from a mobile device or a bot. Show me the setup code.
Prompt 2
Help me add ua-parser-js to a browser page that reads its own user-agent and shows the visitor their browser and OS details.
Prompt 3
I'm using ua-parser-js v2 and need to know if the AGPL license affects my closed-source SaaS product. Explain the implications and options.
Prompt 4
Show me how to use ua-parser-js with Client Hints in Chrome so I get more accurate device data than the traditional user-agent string provides.
Prompt 5
Help me write a middleware function using ua-parser-js that blocks all known AI crawler user-agents from accessing my API.
Open on GitHub → Explain another repo

← faisalman on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.