
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
random-string
Advanced tools
Simple Module for generating Random Strings
Install the module with: npm install random-string
var randomString = require('random-string');
var x = randomString(); // x contains now a random String with the length of 8
You can call the randomString-Method with additional options for specifing how long your resulting string should be and which characters to include
// e.g. you want a string with a length of 20
var x = randomString({length: 20});
number - the length of your resulting string (DEFAULT: 8)
boolean - should your resulting string contain numbers (from 0-9) (DEFAULT: true)
boolean - should your resulting string contain letters (from a-z, lower and uppercase) (DEFAULT: true)
boolean - should your resulting string contain any of these special characters (!$%^&*()_+|~-=`{}[]:;<>?,./) (DEFAULT: false)
array - removes characters from resulting string Note: Lowercase letters will not remove uppercase letters
// that would be a call with all options (hint: thats a call with all defaults, und the options wouldnt be necessary in that case!)
var x = randomString({
length: 8,
numeric: true,
letters: true,
special: false,
exclude: ['a', 'b', '1']
});
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
0.2.0 introduce exclude
-option
0.1.2 fix characterset (#2)
0.1.1 do not contain special cars per default
0.1.0 Initial Release
Copyright (c) 2013 Valiton GmbH Licensed under the MIT license.
FAQs
Simple Module for generating Random Strings
The npm package random-string receives a total of 32,321 weekly downloads. As such, random-string popularity was classified as popular.
We found that random-string demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.