gitwtfhub

wtf is ua-device?

airyland/ua-device — explained in plain English

Analysis updated 2026-08-05 · repo last pushed 2016-04-01

2JavaScriptAudience · developerComplexity · 2/5DormantSetup · easy

TL;DR

A JavaScript library that parses browser user agent strings into structured device, OS, and browser info, with special accuracy for Chinese mobile phone brands that other parsers miss.

Mindmap

mindmap
  root((repo))
    What it does
      Parses UA strings
      Returns device data
      Identifies Chinese brands
    Tech stack
      JavaScript
      Pattern matching
      Scraped model data
    Use cases
      Analytics dashboards
      Device adaptation
      Hardware breakdowns
    Audience
      Product teams
      Analytics builders
      Chinese market focus

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

Why would anyone build with this?

REASON 1

Build an analytics dashboard that accurately reports device breakdowns for Chinese mobile users.

REASON 2

Adapt website layouts or features based on detected device type and manufacturer.

REASON 3

Identify hardware models of visitors to understand what phones your Chinese audience uses.

What's in the stack?

JavaScript

How it stacks up

airyland/ua-device3imed-jaberi/cryptography-si-isamm3imed-jaberi/koa-isomorphic-router
Stars222
LanguageJavaScriptJavaScriptJavaScript
Last pushed2016-04-012021-09-252021-02-06
MaintenanceDormantDormantDormant
Setup difficultyeasyeasyeasy
Complexity2/51/52/5
Audiencedeveloperresearcherdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min

Install via npm and pass in a user agent string, no external services or API keys required.

Wtf does this do

ua-device is a JavaScript library that takes a browser's user agent string, the line of text every browser sends to identify itself, and turns it into structured information about the visitor's device, operating system, and browser. This is useful if you're building analytics, adapting a website for different devices, or just trying to understand what hardware your users are on. Every web browser sends a user agent string when it loads a page, but these strings are messy and inconsistent. The library parses that string and returns a clean object with details like browser name and version, rendering engine, operating system, and hardware info including device type, manufacturer, and model. You pass in the raw string, and it hands you back organized data you can use in your app. What makes this project stand out is its focus on the Chinese mobile market. Many popular UA parsers were built with Western devices in mind and struggle with Chinese phone brands. The README explains that big-name libraries often only identify phone brands correctly 30-40% of the time. This library tackles problems like phones from Xiaomi appearing under multiple inconsistent names, carriers causing different UA strings for the same device, and models getting renamed across production runs. It uses pattern matching and scraped model data from a Chinese electronics database to identify brands that plain UA strings don't reveal. Someone building a Chinese-facing analytics dashboard or a product team wanting accurate device breakdowns for a domestic audience would get the most value here. The test suite reports over 3,200 sample strings with strong recognition rates across most fields, including nearly 88% for device manufacturer, a notably hard field to get right. The tradeoff is specificity. This library is purpose-built for the Chinese market and its messy UA conventions, so it's heavier on that use case than a general-purpose parser. If your users are primarily outside China, a simpler library might serve you fine. But for products serving Chinese mobile users, the extra accuracy on hardware identification is the core benefit.

Yoink these prompts

Prompt 1
Parse this user agent string and give me the browser name, OS, device manufacturer, and model: [paste UA string here]
Prompt 2
Compare ua-device against ua-parser-js for accuracy on Chinese phone brands like Xiaomi, OPPO, and vivo, which gives better device manufacturer detection?
Prompt 3
Set up a small Node script using ua-device to parse a list of user agent strings from a file and output the structured device info as JSON

Frequently asked questions

wtf is ua-device?

A JavaScript library that parses browser user agent strings into structured device, OS, and browser info, with special accuracy for Chinese mobile phone brands that other parsers miss.

What language is ua-device written in?

Mainly JavaScript. The stack also includes JavaScript.

Is ua-device actively maintained?

Dormant — no commits in 2+ years (last push 2016-04-01).

How hard is ua-device to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is ua-device for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.