npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ua-friendly

v1.1.2

Published

Convert User-Agent strings into friendly, human-readable text

Downloads

49

Readme

UA-Friendly

A lightweight JavaScript library that converts technical User-Agent strings into friendly, human-readable text.

Features

  • Parses User-Agent strings to extract browser, OS, and device information
  • Converts technical UA strings into natural language descriptions
  • Customizable output format with options to include/exclude version numbers, OS info, and device info
  • No external dependencies
  • Works in Node.js environments
  • TypeScript support with type definitions

Installation

npm install ua-friendly

Usage

Basic Usage

const { uaToFriendly } = require('ua-friendly');

// Example User-Agent string
const ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36';

// Convert to friendly text
const friendly = uaToFriendly(ua);
console.log(friendly);
// Output: Chrome 91.0.4472.124 on Windows 10 on a Desktop

TypeScript Usage

UA-Friendly includes TypeScript definitions for type safety and better IDE support.

import { uaToFriendly, parseUserAgent, ParsedUserAgent, UAFormatOptions } from 'ua-friendly';

// Example User-Agent string
const ua: string = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36';

// Define options with type safety
const options: UAFormatOptions = {
  includeVersion: true,
  includeOS: true,
  includeDevice: true
};

// Convert to friendly text with type safety
const friendly: string = uaToFriendly(ua, options);
console.log(friendly);

// Get parsed UA data with type safety
const parsed: ParsedUserAgent = parseUserAgent(ua);
console.log(parsed.browser.name); // Chrome

Customizing Output

const { uaToFriendly } = require('ua-friendly');

const ua = 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1';

// Without version numbers
const noVersion = uaToFriendly(ua, { includeVersion: false });
console.log(noVersion);
// Output: Safari on iOS on a Apple iPhone

// Without OS information
const noOS = uaToFriendly(ua, { includeOS: false });
console.log(noOS);
// Output: Safari 14.0 on a Apple iPhone

// Without device information
const noDevice = uaToFriendly(ua, { includeDevice: false });
console.log(noDevice);
// Output: Safari 14.0 on iOS 14.6

Advanced Usage

const { parseUserAgent } = require('ua-friendly');

const ua = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0';

// Get detailed parsed information
const parsed = parseUserAgent(ua);
console.log(parsed);
/* Output:
{
  browser: { name: 'Firefox', version: '89.0' },
  os: { name: 'Linux', version: '' },
  device: { type: 'Desktop', brand: '', model: '' }
}
*/

API Reference

uaToFriendly(uaString, options)

Converts a User-Agent string into a friendly, human-readable description.

  • uaString (string): The User-Agent string to parse
  • options (object, optional): Configuration options
    • includeVersion (boolean): Whether to include version numbers (default: true)
    • includeOS (boolean): Whether to include OS information (default: true)
    • includeDevice (boolean): Whether to include device information (default: true)

Returns a string with the friendly description.

parseUserAgent(uaString)

Parses a User-Agent string into structured data.

  • uaString (string): The User-Agent string to parse

Returns an object containing:

  • browser: Browser information (name, version)
  • os: Operating system information (name, version)
  • device: Device information (type, brand, model)

TypeScript Interfaces

The following TypeScript interfaces are available for type safety:

ParsedUserAgent

interface ParsedUserAgent {
  browser: Browser;
  os: OS;
  device: Device;
}

Browser

interface Browser {
  name: string;
  version: string;
}

OS

interface OS {
  name: string;
  version: string;
}

Device

interface Device {
  type: string;
  brand: string;
  model: string;
}

UAFormatOptions

interface UAFormatOptions {
  includeVersion?: boolean;
  includeOS?: boolean;
  includeDevice?: boolean;
}

Examples

See the examples directory for more usage examples.

License

ISC