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

@rahulxf/random-user-agent

v1.4.0

Published

Generate random user agent

Readme

Random User Agents

npm version

Github

Description

A simple yet powerful NPM package to generate random user agents effortlessly. Whether you're working on web scraping, testing, or automation, this tool provides flexibility to create one or many user agents in seconds.


Features

  • Generate single or multiple user agents.
  • Built with TypeScript for type safety and maintainability.
  • Tested with Vitest and formatted with Prettier for consistent code quality.
  • Fully automated CI/CD pipeline via GitHub Actions.
  • Generate user agent - Chrome, Firefox, Edge, Android
  • Customize Your User Agent and filter out which browser you want
  • All in one Random User Agent generateUserAgentRandom

Use this package with Puppeteer

Getting Started

Installation is done using the npm install command:

npm i @rahulxf/random-user-agent
import { generateUserAgents } from '@rahulxf/random-user-agent';

// Generate 5 user agents
const value = generateUserAgents(5);
console.log(value);

Result

[
  'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.350.56 Safari/537.36',
  'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.344.67 Safari/537.36',
  'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.259.94 Safari/537.36',
  'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.434.38 Safari/537.36',
  'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.123.89 Safari/537.36'
]

Other Example

Here is implementation of each and every things

| Function | Description | | ------------------------- | ------------------------------------------------------------------- | | generateAndroidAgents | Generate android agents(>1), max_count is required field | | generateEdgeAgents | Generate edge agents(>1), max_count is required field | | generateFirefoxAgents | Generate firefox agents(>1), max_count is required field | | generateUserAgentOnType | Generate user agent based on types(firefox, chrome, edge, android). | | getAndroidAgent | get one android agent | | getEdgeAgent | get one edge agent | | getFirefoxAgent | get one firefox agent | | getUserAgent | get one chrome agent | | generateUserAgentRandom | generate random user agent include each types |

Example

console.log({
  generateAndroidAgents: generateAndroidAgents(10),
  generateEdgeAgents: generateEdgeAgents(10),
  generateFirefoxAgents: generateFirefoxAgents(10),
  'generateUserAgentOnType:Firefox': generateUserAgentOnType({
    options: {
      type: 'firefox',
    },
  }),
  'generateUserAgentOnType:Chrome': generateUserAgentOnType({
    options: {
      type: 'chrome',
    },
  }),
  'generateUserAgentOnType:Android': generateUserAgentOnType({
    options: {
      type: 'android',
    },
  }),
  'generateUserAgentOnType:edge': generateUserAgentOnType({
    options: {
      type: 'edge',
    },
  }),
  getAndroidAgent: getAndroidAgent(),
  getEdgeAgent: getEdgeAgent(),
  getFirefoxAgent: getFirefoxAgent(),
  generateUserAgents: generateUserAgents(10),
  getUserAgent: getUserAgent(),
  generateUserAgentRandom: generateUserAgentRandom(),
});

Result

{
  generateAndroidAgents: [
    'Mozilla/5.0 (Linux; Android 12; moto g pure) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36',
    'Mozilla/5.0 (Linux; Android 12; moto g stylus 5G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Mobile Safari/537.36',
    'Mozilla/5.0 (Linux; Android 12; moto g power (2022)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36',
    ... more items
  ],

  generateEdgeAgents: [
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.457.29 Safari/537.36 Edg/114.457.29',
    'Mozilla/5.0 (X11; Ubuntu i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.427.17 Safari/537.36 Edg/111.427.17',
    'Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.303.22 Safari/537.36 Edg/115.303.22',
    ... more items
  ],

  generateFirefoxAgents: [
    'Mozilla/5.0 (X11; Linux x86_64; rv:110.0) Gecko/20100101 Firefox/110.0',
    'Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0',
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0',
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0',
    ... more items
  ],

  'generateUserAgentOnType:Firefox': 'Mozilla/5.0 (Windows NT 11.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0',
  'generateUserAgentOnType:Chrome': 'Mozilla/5.0 (X11; Fedora i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.374.92 Safari/537.36',
  'generateUserAgentOnType:Android': 'Mozilla/5.0 (Linux; Android 13; SM-A536B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36',
  'generateUserAgentOnType:edge': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.216.30 Safari/537.36 Edg/114.216.30',
  getAndroidAgent: 'Mozilla/5.0 (Linux; Android 13; Pixel 6 Pro) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Mobile Safari/537.36',
  getEdgeAgent: 'Mozilla/5.0 (X11; Ubuntu i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.362.48 Safari/537.36 Edg/111.362.48',
  getFirefoxAgent: 'Mozilla/5.0 (X11; Linux x86_64; rv:115.0) Gecko/20100101 Firefox/115.0',

  generateUserAgents: [
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.52 Safari/537.36',
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.485.20 Safari/537.36',
    'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.355.31 Safari/537.36',
    ... more items
  ],

  getUserAgent: 'Mozilla/5.0 (X11; Ubuntu i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.79.79 Safari/537.36',

  generateUserAgentRandom: [
    'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:113.0) Gecko/20100101 Firefox/113.0',
    'Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0',
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 14.7; rv:123.0) Gecko/20100101 Firefox/123.0',
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 14.7; rv:119.0) Gecko/20100101 Firefox/119.0',
    'Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0',
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/109.0',
    'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0',
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0',
    ... 9992 more items
  ]
}

Generate a single user agent:

  • getUserAgent() method
import { getUserAgent } from '@rahulxf/random-user-agent';

console.log(getUserAgent());

// 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.123.89 Safari/537.36'

// You can also specify the count (optional)
console.log(getUserAgent(10));

Development & Contribution

If you'd like to contribute or run the project locally:

  1. Clone the repository:

    git clone https://github.com/manzil-infinity180/random-user-agent.git
    cd random-user-agent
    npm install
  2. Run tests:

    npm run test
  3. Ensure changes meet the project's standards:

    npm run ci

This project uses TypeScript for development, Vitest for testing, and Prettier for formatting. All contributions are welcome!


Technology Stack

  • Languages & Tools: TypeScript, JavaScript, Node.js
  • Testing: Vitest
  • Code Formatting: Prettier
  • Automation: GitHub Actions

Package Details

Here's an overview of the key NPM scripts included:

| Script | Description | | --------------- | -------------------------------------------------- | | build | Compiles TypeScript files to JavaScript. | | ci | Runs all checks (build, format, exports, tests). | | format | Formats code using Prettier. | | test | Runs tests using Vitest. | | local-release | Handles changeset versioning and local publishing. |


License

This project is licensed under the MIT License, allowing developers to use, modify, and share freely.