express-device, node-device-detector, and ua-parser-js are all npm packages designed to parse HTTP User-Agent strings to identify client devices, browsers, and operating systems. These tools help developers tailor responses or experiences based on the detected client characteristics. ua-parser-js is a general-purpose, framework-agnostic library focused purely on parsing. express-device is an Express.js middleware that automatically attaches device info to the request object. node-device-detector offers more detailed device classification with support for modern detection techniques beyond basic User-Agent parsing.
Parsing User-Agent strings to detect devices, browsers, and operating systems is a common need in web applications—for analytics, responsive rendering, or compatibility checks. But not all detection libraries are created equal. Let’s compare express-device, node-device-detector, and ua-parser-js from a practical engineering standpoint.
express-device is Express-specific middleware. It hooks into your Express app and automatically adds a req.device property so you can check device type inside route handlers.
// express-device: automatic injection into req
const express = require('express');
const device = require('express-device');
const app = express();
app.use(device.capture());
app.get('/', (req, res) => {
// req.device.type is 'phone', 'tablet', or 'desktop'
res.send(`You're on a ${req.device.type}`);
});
ua-parser-js is a pure parser with no framework dependencies. You pass it a User-Agent string and get back structured data about browser, OS, and device.
// ua-parser-js: manual parsing, works anywhere
const UAParser = require('ua-parser-js');
const ua = 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) ...';
const parser = new UAParser(ua);
const result = parser.getResult();
// { browser: { name: 'Mobile Safari', version: '16.5' },
// os: { name: 'iOS', version: '16.5' },
// device: { vendor: 'Apple', model: 'iPhone', type: 'mobile' } }
node-device-detector is a full-featured detector that goes beyond basic parsing. It uses an extensive internal database and additional heuristics to identify exact device models.
// node-device-detector: detailed device identification
const DeviceDetector = require('node-device-detector');
const detector = new DeviceDetector();
const ua = 'Mozilla/5.0 (Linux; Android 13; SM-S908B) ...';
const result = detector.detect(ua);
// { os: { name: 'Android', version: '13' },
// client: { type: 'browser', name: 'Chrome' },
// device: { type: 'smartphone', brand: 'Samsung', model: 'Galaxy S22+' } }
The level of detail varies significantly:
express-device only tells you if the device is a phone, tablet, or desktop. It doesn’t identify brands, models, or even distinguish between iOS and Android.// express-device output example
req.device.type; // 'phone' — that’s it
ua-parser-js provides vendor, model, and device type, but its device detection is limited to what’s inferable from the User-Agent alone. Many Android devices appear as generic "Generic Smartphone".// ua-parser-js may return:
result.device; // { vendor: 'Samsung', model: 'SM-G975F', type: 'mobile' }
// But often:
result.device; // { vendor: undefined, model: undefined, type: 'mobile' }
node-device-detector maintains a large, frequently updated regex-based device database (similar to what commercial services use). It reliably identifies specific models like iPhone 14 Pro or Xiaomi Redmi Note 12.// node-device-detector output
result.device; // { type: 'smartphone', brand: 'Apple', model: 'iPhone 14 Pro' }
If your use case depends on knowing whether a user is on an iPhone 12 vs iPhone 13, only node-device-detector delivers consistently.
express-device is tightly coupled to Express. You can’t use it in Koa, Fastify, or frontend code. It also runs on every request, which may be unnecessary overhead if you only need device info on certain routes.
ua-parser-js works everywhere — browser, Node.js, Deno, or even React Native. You decide when and where to parse, and you can cache parsers for performance.
// Reuse parser instance for better performance
const parser = new UAParser();
function handleRequest(ua) {
parser.setUA(ua);
return parser.getDevice();
}
node-device-detector is Node.js-only (due to its large internal database), but it’s framework-agnostic. You can use it in any server environment by manually passing the User-Agent header.
// Works in any Node.js HTTP server
app.get('/', (req, res) => {
const device = detector.detect(req.headers['user-agent']);
// ...
});
As of 2024, express-device shows signs of abandonment: its last meaningful update was years ago, and it relies on outdated detection logic. New devices often get misclassified or fall back to generic categories.
In contrast, both ua-parser-js and node-device-detector are actively maintained. ua-parser-js syncs regularly with the official UAParser community regexes. node-device-detector updates its internal database frequently and supports modern detection patterns beyond raw User-Agent parsing (like client hints, though that requires additional setup).
⚠️ Important: Because
express-deviceis effectively unmaintained and lacks accuracy, it should not be used in new projects. Even for simple Express apps, callingua-parser-jsmanually inside middleware gives you better results with minimal extra code.
You want to redirect mobile users to /m.
express-device — too unreliable.ua-parser-js with custom middleware:const UAParser = require('ua-parser-js');
app.use((req, res, next) => {
const parser = new UAParser(req.headers['user-agent']);
const deviceType = parser.getDevice().type;
if (deviceType === 'mobile' && !req.url.startsWith('/m')) {
return res.redirect('/m' + req.url);
}
next();
});
You’re building an internal tool that displays which phone models your users have.
node-device-detectorconst detector = new DeviceDetector();
const { device } = detector.detect(userAgent);
// Log: { brand: 'Google', model: 'Pixel 7' }
You need to warn users on old browsers.
ua-parser-jsconst parser = new UAParser(navigator.userAgent);
const browser = parser.getBrowser();
if (browser.name === 'IE' || (browser.name === 'Chrome' && parseFloat(browser.version) < 80)) {
showUpgradeWarning();
}
| Feature | express-device | node-device-detector | ua-parser-js |
|---|---|---|---|
| Framework Coupling | Express-only | None (Node.js only) | None (universal) |
| Device Detail Level | Type only (3 categories) | Full model + brand + type | Vendor/model if available |
| Accuracy | Low | High | Medium |
| Maintenance Status | Unmaintained | Actively maintained | Actively maintained |
| Use in Frontend? | No | No | Yes |
| Good For | Legacy Express apps | Analytics, ad tech, precise UX | General parsing, feature detection |
express-device in new code. Its convenience isn’t worth the technical debt.ua-parser-js for most general-purpose User-Agent parsing — it’s reliable, lightweight, and works everywhere.node-device-detector only when you truly need high-fidelity device identification and are operating in a Node.js backend context.Remember: User-Agent parsing is inherently imperfect. For critical functionality, always combine it with progressive enhancement and feature detection (e.g., using @mdn/browser-compat-data or runtime checks) rather than relying solely on device labels.
Choose ua-parser-js when you need a lightweight, battle-tested, and actively maintained library that parses User-Agent strings into structured browser, OS, and device data without framework coupling. It’s ideal for both frontend and backend use, offers excellent cross-platform support, and gives you full control over how results are used—perfect for feature detection, logging, or conditional logic outside of Express middleware.
Choose node-device-detector when you need high-accuracy device identification—including specific models like 'iPhone 14' or 'Samsung Galaxy S23'—and are willing to accept a slightly heavier dependency. It combines User-Agent parsing with additional heuristics and maintains an up-to-date device database, making it suitable for analytics, ad targeting, or responsive rendering decisions that depend on precise hardware info.
Choose express-device only if you're working within an Express.js application and need a quick, zero-config way to attach basic device type (e.g., desktop, mobile, tablet) to each incoming request. It’s convenient but limited in accuracy and detail, and hasn’t seen active maintenance in recent years — avoid it for new projects requiring reliable or granular device detection.
The most comprehensive, compact, and up-to-date JavaScript library to detect user's browser, OS, CPU, and device type/model. Also detect bots, apps, and more. Runs seamlessly in the browser (client-side) or Node.js (server-side).
version 1.x : https://github.com/faisalman/ua-parser-js/tree/1.0.x#documentationversion 2.x : https://docs.uaparser.devBefore upgrading from v0.7 / v1.0, please read CHANGELOG to
see what's new & breaking.
| Open-Source Editions | PRO / Commercial Editions | ||||
|---|---|---|---|---|---|
| License options | MIT (v1.x) | AGPL (v2.x) | PRO Personal | PRO Business | PRO Enterprise |
| Browser Detection | ⚠️ | ✅ | ✅ | ✅ | ✅ |
| CPU Detection | ⚠️ | ✅ | ✅ | ✅ | ✅ |
| Device Detection | ⚠️ | ✅ | ✅ | ✅ | ✅ |
| Rendering Engine Detection | ⚠️ | ✅ | ✅ | ✅ | ✅ |
| OS detection | ⚠️ | ✅ | ✅ | ✅ | ✅ |
| Enhanced+ Accuracy | ❌ | ✅ | ✅ | ✅ | ✅ |
| Bot Detection | ❌ | ✅ | ✅ | ✅ | ✅ |
| AI Detection | ❌ | ✅ | ✅ | ✅ | ✅ |
| Extra Detections (Apps, Libs, Emails, Media Players, Crawlers, and more) | ❌ | ✅ | ✅ | ✅ | ✅ |
| Client Hints Support | ❌ | ✅ | ✅ | ✅ | ✅ |
| CommonJS Support | ✅ | ✅ | ✅ | ✅ | ✅ |
| ESM Support | ❌ | ✅ | ✅ | ✅ | ✅ |
| TypeScript Definitions | ✅ | ✅ | ✅ | ✅ | ✅ |
| npm Module Available | ✅ | ✅ | ✅ | ✅ | ✅ |
| Direct Downloads Available | ✅ | ✅ | ✅ | ✅ | ✅ |
| Commercial Use Allowed | ✅ | ✅ | ❌ | ✅ | ✅ |
| Permissive (non-Copyleft) License | ✅ | ❌ | ✅ | ✅ | ✅ |
| No Open-Source Obligations | ✅ | ❌ | ✅ | ✅ | ✅ |
| Unlimited End-Products | ✅ | ✅ | ✅ | ❌ | ✅ |
| Unlimited Deployments | ✅ | ✅ | ✅ | ❌ | ✅ |
| 1-year Product Support | ❌ | ❌ | ✅ | ✅ | ✅ |
| Lifetime Updates | ✅ | ✅ | ✅ | ✅ | ✅ |
| Price | FREE* (License) | FREE* (License) | $14 (License) | $29 (License) | $599 (License) |
GET THE PRO PACKAGES 📥 | |||||
Please read CONTRIBUTING guide first for the instruction details.
Made with contributors-img.
Support the open-source editions of UAParser.js through one of the following options: