Generate random strings of letters and digits, 4 to 128 long, up to 1,000 at a time, with the entropy in bits
Generate random strings from the characters you pick, for test data, invite codes, file names, salts and IDs.
How to use it
Set the length and pick the characters: lowercase, capitals, digits, symbols. Set How many, up to 1,000. Copy the list or download it as a text file, one string per line.
Examples
Letters and digits
Input
Length 32 · a–z A–Z 0–9
Result
8PZhMkGAYlE8550G9iGtzDEAUAGoxLL1
190 bits: each of 62 characters, with at least one of each kind.
A short URL-safe token
Input
Base64url · 16 bytes
Result
eM-J16R3pi_-HU0trUj4Vw
128 bits in 22 characters, safe in a URL as it is.
Readable codes
Random enough for what
Test data and file names: any length; uniqueness is what matters, and 16 characters of letters and digits give 95 bits. Salts and nonces: 16 random bytes (128 bits) is the common size; Hex or Base64url give exactly that. Secrets and tokens: at least 128 bits, as on the API key generator .
Questions
- Is this better than Math.random() in my code?
For anything secret, yes: Math.random is not a cryptographic generator and its output can be predicted. This page uses crypto.getRandomValues; in your own code use crypto.getRandomValues or crypto.randomUUID in the browser and Node.js, or secrets in Python. - Can two strings come out the same?
With 32 letters and digits there are about 2^190 possible strings, so a repeat is not a practical concern. Short strings repeat sooner: turn on No repeats and each list holds every string once (it says so when the settings allow fewer different strings than you asked for), and check uniqueness in your database if you use them as IDs. - How long should a random string be?
It depends on the job. For test data and file names only uniqueness matters: 16 letters and digits give 95 bits. Salts and nonces are usually 16 random bytes (128 bits), which Hex or Base64url give exactly. Secrets and tokens need at least 128 bits.