I think this will work for you:
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
console.log(makeid(5));
Answer from csharptest.net on Stack OverflowRANDOM.ORG
random.org › strings
RANDOM.ORG - String Generator
This page allows you to generate random text strings using true randomness, which for many purposes is better than the pseudo-random number algorithms typically used in computer programs.
GitHub
github.com › ITsPorky › Character-Generation-API
GitHub - ITsPorky/Character-Generation-API: The Character Generation API is a Node.js application that can generate random RPG characters with Stats, Art, and general information about the character. · GitHub
The Character Generation API is a Node.js application that can generate random RPG characters with Stats, Art, and general information about the character. - ITsPorky/Character-Generation-API
Author ITsPorky
Top answer 1 of 16
3768
I think this will work for you:
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
console.log(makeid(5));
2 of 16
3232
//Can change 7 to 2 for longer results.
let r = (Math.random() + 1).toString(36).substring(7);
console.log("random", r);
Note: The above algorithm has the following weaknesses:
- It will generate anywhere between 0 and 6 characters due to the fact that trailing zeros get removed when stringifying floating points.
- It depends deeply on the algorithm used to stringify floating point numbers, which is horrifically complex. (See the paper "How to Print Floating-Point Numbers Accurately".)
Math.random()may produce predictable ("random-looking" but not really random) output depending on the implementation. The resulting string is not suitable when you need to guarantee uniqueness or unpredictability.- Even if it produced 6 uniformly random, unpredictable characters, you can expect to see a duplicate after generating only about 50,000 strings, due to the birthday paradox. (sqrt(36^6) = 46656)
ACM
helloacm.com › random
Random String Generator (Password)
The Random API is implemented as a CloudFlare Serverless Function which runs on the CloudFlare Edge Network Nodes. You may implement one and host it on cloudflare's Free-Tier worker plan (10M per day). function generateRandomString($length, $bitmask) { $uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; ...
Randommer
randommer.io
Generate Random Data API - Randommer
Generate free random numbers, phone numbers, names list, security numbers, validate telephones and everything that is random. Free API support is included
CodePen
codepen.io › sandrakrle › pen › pVpJKZ
StarWars API - Get Random SW Character
Check it out in the apicall.js! --> <button type="button" class="btn btn-primary" onclick="getData();"> Get random character <i class="fa fa-sync"></i> </button> <div class="container data-holder invisible"> <div>Name: <span id="name"></span></div> <div>Height: <span id="height"></span></div> <div>Mass: <span id="mass"></span></div> <div>Hair Color: <span id="hair_color"></span></div> <div>Skin Color: <span id="skin_color"></span></div> <div>Eye Color: <span id="eye_color"></span></div> <div>Birth Year: <span id="birth_year"></span></div> <div>Gender: <span id="gender"></span></div> </div> </div> </body>
Apache Commons
commons.apache.org › proper › commons-lang › javadocs › api-3.9 › org › apache › commons › lang3 › RandomStringUtils.html
RandomStringUtils (Apache Commons Lang 3.9 API)
Characters will be chosen from the set of all characters. ... Creates a random string whose length is the number of characters specified.
Random User Generator
randomuser.me
Random User Generator | Home
Random user generator is a FREE API for generating placeholder user information. Get profile photos, names, and more. It's like Lorem Ipsum, for people.
Random User Generator
randomuser.me › documentation
Random User Generator | Documentation
https://randomuser.me/api/?password=upper,lower,1-16 · The example above would generate a password consisting of uppercase and lowercase characters ranging between 1 to 16 characters long.
GitHub
github.com › kentcdodds › marvel-random
GitHub - kentcdodds/marvel-random: Get random marvel characters.
Get random marvel characters. Use it if you want to... You must call this first. Simply set it with your public API key obtained from developer.marvel.com and then you can proceed to make api calls.
Author kentcdodds
Userback
userback.io › tools › random-string-generator
Random String Generator - Secure Password & API Key Generator | Userback
January 18, 2026 - Enter the desired length of your random string and select a character set (alphanumeric, password, URL-safe, or custom). Choose how many strings to generate and click Generate. The tool will create cryptographically secure random strings instantly. Perfect for generating WordPress API keys, passwords, and secure tokens.
GitHub
github.com › oscardavidrm › random-character-generator-API
GitHub - dmosc/random-character-generator-API: API service for random-character-generator application built with Express, MongoDB, Mongoose and GraphQL.
API service for random-character-generator application built with Express, MongoDB, Mongoose and GraphQL. - dmosc/random-character-generator-API
Author dmosc
Top answer 1 of 16
3768
I think this will work for you:
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
console.log(makeid(5));
2 of 16
3232
//Can change 7 to 2 for longer results.
let r = (Math.random() + 1).toString(36).substring(7);
console.log("random", r);
Note: The above algorithm has the following weaknesses:
- It will generate anywhere between 0 and 6 characters due to the fact that trailing zeros get removed when stringifying floating points.
- It depends deeply on the algorithm used to stringify floating point numbers, which is horrifically complex. (See the paper "How to Print Floating-Point Numbers Accurately".)
Math.random()may produce predictable ("random-looking" but not really random) output depending on the implementation. The resulting string is not suitable when you need to guarantee uniqueness or unpredictability.- Even if it produced 6 uniformly random, unpredictable characters, you can expect to see a duplicate after generating only about 50,000 strings, due to the birthday paradox. (sqrt(36^6) = 46656)
RandomKeygen
randomkeygen.com
RandomKeygen - Free Secure Password & Key Generator
Generate cryptographically secure passwords, API keys, UUIDs, and more. Free and runs entirely in your browser.
Name Parser
parser.name › name parser › api › generate random names with the name parser api
Generate random names with the Name Parser API
This API endpoint generates names by combining a random first name and a random surname for any given country code.
Raymond Camden
raymondcamden.com › 2017 › 06 › 19 › serverless-demo-random-comic-book-character-via-comic-vine-api
Serverless Demo - Random Comic Book Character via Comic Vine API
On the flip side, I do want to call out something I think the Comic Vine API does very well. I love the status report of your usage: Specifically (and I called it out with the arrow) - I love the "Your request rate is fine" comment. It's a small thing, but it's a plain English summary of my status that doesn't make me look at raw numbers and figure out how much I'm abusing the rate limits. Alright, so with that out of the way - what did I build? I've previously shown how to get a random comic book character from the Marvel API (All My Friends are Superheros) as well as random comic book covers (Building a Twitter bot to display random comic book covers).
Namefake
en.namefake.com › api
API - Fake Name Generator
You can also specify gender and country for the generated name. For example: //api.name-fake.com/ukrainian-ukraine/male/ If you need to generate names randomly then you can use //api.name-fake.com/random/random.
Orbit2x
orbit2x.com › random-string
Random String Generator - Secure Passwords & API Tokens
Generate cryptographically secure random strings for passwords, API tokens, and keys. Custom length, character sets, bulk generation. Free tool.
Sentry
sentry.io › sentry answers › javascript › generate random string/characters in javascript
Generate random string/characters in JavaScript | Sentry
The crypto.getRandomValues method populates the Uint8Array array with random numbers with a value between 0 and 255. We then loop through this array to create a random string. Each character of the random string uses the random number in the randomArray and the modulo operator to select one of the allowed characters in the chars string.