parseClient(input?)Synchronously classifies a User-Agent string or a ClientEvidence object.
Documentation / Overview
client-parser is a tiny, type-safe client classifier for User-Agent strings, Client Hints, and HTTP headers. It reports what it found, where it found it, and how confident the classification is.
Use these signals for analytics, diagnostics, and presentation hints—not authentication, authorization, or browser capability checks.
Install from npm with your preferred package manager.
$ npm install client-parserPass a User-Agent string to parseClient. Unavailable details are omitted rather than filled with placeholders.
import { parseClient } from 'client-parser'
const client = parseClient(
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_5...)',
)
console.log(client.device.type) // "mobile"
console.log(client.browser.name) // "Chrome"
console.log(client.os.name) // "iOS"
console.log(client.engine.name) // "WebKit"
console.log(client.isMobile) // trueThe default export is also parseClient. CommonJS consumers can use require('client-parser').
Pass a plain header object or any object with a Headers-compatible get() method. Header names are case-insensitive.
import { parseClient } from 'client-parser'
const client = parseClient({
headers: request.headers,
})Supported headers include Sec-CH-UA, full versions, mobile, platform, architecture, bitness, model, and WoW64.
parseNavigator collects high-entropy hints when available and falls back gracefully when they are denied or unsupported.
import { parseNavigator } from 'client-parser'
const client = await parseNavigator(navigator)The browser and server policy decide which values are exposed. Always expect a partial result.
parseClient(input?)Synchronously classifies a User-Agent string or a ClientEvidence object.
parseNavigator(navigatorLike)Asynchronously collects browser evidence and classifies the result.
parseClientHintHeaders(headers)Normalizes Sec-CH-UA-* headers into the Client Hints shape.
getDeviceType(input?)deprecatedCompatibility alias for parseClient. Use the new name in new code.
The stable top-level result lets consumers use narrow signals without reparsing raw input.
User-Agent strings can be reduced, spoofed, or ambiguous. Client Hints are structured but not universal. Use source and confidence to account for those limits.