Free tool · Developer tools
Random string generator
This random string generator makes as many strings as you want, at the length and from the characters you choose. With the starting settings, 16 characters from a pool of 62 give 95.3 bits, which is 4.77 × 10^28 possible strings.
- Free
- No sign-up
- Runs in your browser
- 5 strings
- 16 characters each
- 62 in the pool
- 95.3 bits each
- Pool
- ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
- Possible strings
- 4.77 × 10^28
How to use the Random String Generator
- Set the Length of each string and How many strings you need.
- Pick Characters to use, such as letters and digits, hex or URL-safe, or choose My own characters and type the alphabet yourself.
- Under Rules, leave out look-alike characters or forbid a repeated character inside one string.
- Choose how to show them: one per line, a JSON array or comma separated. Press Copy, or Generate new strings for a fresh set.
How does a random string generator work?
The generator holds a pool of allowed characters and, for every position in the string, picks one at random. Each pick uses the browser's cryptographic source, crypto.getRandomValues, which gives a 32-bit number. A plain remainder would make low positions slightly likelier whenever the pool size does not divide 2^32 evenly, so numbers from the top sliver of the range are discarded and drawn again. After that, all 62 characters of the default pool have the same chance, 1 in 62, at every position.
The size of the pool and the length together set how many strings are possible: pool size to the power of the length. For 16 characters from 62 that is 4.77 × 10^28. Taking the base 2 logarithm gives the strength in bits, 16 × log2(62) = 95.3. The page shows both figures under every result.
How long should a random string be?
Length is the lever you control, and the character set decides how much each position adds. Digits give log2(10) = 3.32 bits per character, lowercase letters 4.70, and letters plus digits 5.95. The table runs the same three lengths through five pools.
A 32 character hex string holds exactly 128 bits, because every hex digit is 4 bits. To match that with letters and digits you need 22 characters, since 22 characters from the pool of 62 give 131.0 bits. Pick the length by the number of bits you need, not by how long the string looks.
| Pool | Characters | 8 long | 16 long | 32 long |
|---|---|---|---|---|
| Letters and digits | 62 | 47.6 | 95.3 | 190.5 |
| Lowercase letters | 26 | 37.6 | 75.2 | 150.4 |
| Digits | 10 | 26.6 | 53.2 | 106.3 |
| Hex, lowercase | 16 | 32.0 | 64.0 | 128.0 |
| URL-safe | 64 | 48.0 | 96.0 | 192.0 |
Which character set should I choose?
Pick the pool the place you will use the string accepts, then adjust the length to reach the bits you want. Hex has 16 characters, exactly 4 bits each, and its strings are easy to check by eye. The URL-safe pool is letters and digits plus a hyphen and a low line (_), 64 characters in all, so every character is exactly 6 bits. Digits alone suit codes typed on a keypad, at 3.32 bits each, so they need to be longer.
The output format only changes how the same strings are written. One per line pastes into a text file or a spreadsheet column, the JSON array pastes into code or a test fixture, and the comma separated line fits a configuration value. Copy takes exactly what the result box shows.
If you pick My own characters, type the alphabet in the box, and each different character counts once. Typing abcabc gives a pool of 3, not 6. Any character works, including accented letters, emoji flags and family emoji, and each counts as one position. A letter with a combining accent, a flag or a joined emoji stays in one piece instead of being split into its parts.
| Character set | Pool size | Bits per character |
|---|---|---|
| Digits (0-9) | 10 | 3.32 |
| Hex, lowercase (0-9, a-f) | 16 | 4.00 |
| Lowercase letters (a-z) | 26 | 4.70 |
| Letters (A-Z, a-z) | 52 | 5.70 |
| Letters and digits (A-Z, a-z, 0-9) | 62 | 5.95 |
| URL-safe (A-Z, a-z, 0-9, - and _) | 64 | 6.00 |
What do look-alikes and no repeats change?
Leaving out the look-alikes 0, O, 1, l and I takes the default pool from 62 to 57 and the 16 character string from 95.3 to 93.3 bits. That is a small price for a string someone has to read aloud or copy by eye.
No repeats means each character may appear once in a string. It shrinks the number of possible strings: ten digits in any order make 10 × 9 × 8 × ... × 1 = 3,628,800 strings against 10,000,000,000 when repeats are allowed. Five different digits give 30,240 against 100,000. The length cannot be larger than the pool when this rule is on, and the page tells you when it is.
For a password, the page about password generation adds rules suited to logins, and for identifiers with a fixed layout the UUID generator is the better fit. This page is for everything between: test data, codes, tokens for your own projects and placeholder text.
Use it with
- Random Number Generator: numbers in a range, no repeats.
- Password Generator: strong random passwords.
- Random Word Generator: random nouns, verbs, adjectives.
Questions
How random are the strings?
Every character is drawn with the browser cryptographic generator, and draws that would favor some characters are redone, so each character in the pool is equally likely at each position.
How many bits is a 16 character letters and digits string?
95.3 bits: 16 × log2(62). That is 4.77 × 10^28 possible strings.
Can I use my own characters?
Yes. Choose My own characters and type them in the box. Each different character counts once, so duplicates do not change the odds.
What does the no repeats rule do?
No character appears twice in one string. The number of strings drops, for example from 10,000,000,000 to 3,628,800 for ten digits, and the length cannot exceed the pool size.
How many strings can I make at once?
Up to 500 strings, and the length times the count can be at most 100,000 characters. Copy the list as lines, a JSON array or a comma separated line.
Are my settings or results saved?
No. Strings are made in the page and are not stored or sent, and they disappear when you close the tab.
The tool's results are computed in your browser by the code on this page; the explanations are checked against the tool's own output.