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

user-agent-smith

v1.1.3

Published

A super fast utility designed to generate random user agent strings for various browsers and operating systems.

Readme

User Agent Smith

The UserAgentSmith class is a JavaScript utility designed to generate random user agent strings for various browsers and operating systems. This can be useful for testing web applications, simulating browser requests, or web scraping scenarios where diverse user agents are needed.

Agent Smith

Install

To install the user-agent-smith package, use one of the following commands:

npm install user-agent-smith

Or via Yarn:

yarn add user-agent-smith

Note: The Yarn command uses yarn add instead of yarn install because yarn add is the standard way to add a new package to your project dependencies, while yarn install is typically used to install all dependencies listed in package.json.

Usage

Here’s how to import and instantiate the UserAgentSmith class:

import UserAgentSmith from 'user-agent-smith';

const generator = new UserAgentSmith();

You can then call its methods to generate user agent strings. Run your script with:

node example.mjs

Methods

generate()

Generates a random user agent string with a bias towards popular browsers (e.g., Chrome, Firefox).

Example

console.log(generator.generate());

Sample Output

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.6789.12 Safari/537.36

generateMobile()

Generates a random mobile user agent string (e.g., Chrome on Android, Safari on iOS).

Example

console.log(generator.generateMobile());

Sample Output

Mozilla/5.0 (Linux; Android 13.0; OnePlus 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.3456.78 Mobile Safari/537.36

generateMultiple(count)

Generates a specified number of unique user agent strings.

Parameters

  • count: The number of unique user agents to generate (integer).

Example

console.log(generator.generateMultiple(3));

Sample Output

[
  "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.5678.90 Safari/537.36",
  "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_0; rv:127.0) Gecko/20230101 Firefox/127.0",
  "Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.567.89"
]

Full Usage Example

Here’s a complete example demonstrating how to use the UserAgentSmith class in a modern Node.js script with MJS syntax:

// example.mjs
import UserAgentSmith from 'user-agent-smith';

const generator = new UserAgentSmith();

// Generate a single random user agent
console.log("Random User Agent:");
console.log(generator.generate());

// Generate a single mobile user agent
console.log("\nRandom Mobile User Agent:");
console.log(generator.generateMobile());

// Generate multiple unique user agents
console.log("\nMultiple User Agents:");
console.log(generator.generateMultiple(3));

To run this script:

node example.mjs

Sample Output

Random User Agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.6789.12 Safari/537.36

Random Mobile User Agent:
Mozilla/5.0 (Linux; Android 13.0; OnePlus 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.3456.78 Mobile Safari/537.36

Multiple User Agents:
[
  "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.5678.90 Safari/537.36",
  "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_0; rv:127.0) Gecko/20230101 Firefox/127.0",
  "Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.567.89"
]