
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
random-useragent
Advanced tools
Get a random user agent (with an optional filter to select from a specific set of user agents).
Install the module with: npm install random-useragent
const randomUseragent = require('random-useragent');
randomUseragent.getRandom(); // gets a random user agent string
Get a random user agent string (optionally using a filter).
Example Result:
'Mozilla/5.0 (Windows NT 6.2; rv:20.0) Gecko/20121202 Firefox/20.0'
Get a random user agent's parsed data (optionally using a filter).
Example Result:
{
"folder": "/Browsers - Windows/Legacy Browsers",
"description": "Firefox 20.0 (Win 8 32)",
"userAgent": "Mozilla/5.0 (Windows NT 6.2; rv:20.0) Gecko/20121202 Firefox/20.0",
"appCodename": "",
"appName": "",
"appVersion": "",
"platform": "",
"vendor": "",
"vendorSub": "",
"browserName": "Firefox",
"browserMajor": "20",
"browserVersion": "20.0",
"deviceModel": "",
"deviceType": "",
"deviceVendor": "",
"engineName": "Gecko",
"engineVersion": "20.0",
"osName": "Windows",
"osVersion": "8",
"cpuArchitecture": ""
}
Get an array of all the user agent strings (optionally using a filter).
Get an array of all the parsed user agent data (optionally using a filter).
Get a random user agent string:
randomUseragent.getRandom();
Get a random Firefox user agent string:
randomUseragent.getRandom(function (ua) {
return ua.browserName === 'Firefox';
});
Get a random user agent with a version >= 20:
randomUseragent.getRandom(function (ua) {
return parseFloat(ua.browserVersion) >= 20;
});
The collection of user agents is pulled from the large, regularly updated xml file provided by the author of User Agent Switcher, which is located here:
Copyright (c) 2014 skratchdot
Licensed under the MIT license.
0.5.0 (2020-09-03)
Closed issues:
Merged pull requests:
FAQs
Get a random useragent (with an optional filter)
The npm package random-useragent receives a total of 41,324 weekly downloads. As such, random-useragent popularity was classified as popular.
We found that random-useragent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.