SSOGEN / Free tools / Random String Generator: Secure, Free, in Your Browser
Free tool
Random String Generator: Secure, Free, in Your Browser
A random string generator makes text with no pattern: a test ID, a nonce, a token, a salt. This free one uses the browser's cryptographic random source, shows the entropy in bits, and sends nothing anywhere.
Generate a random string here
Set the length, select a preset or tick the characters you want, and press Generate; nothing is produced until you do.
Leave out look-alikes drops the characters 0 O 1 l I |, which helps when someone has to read the string aloud or type it from a screen. It applies only to the “choose characters” mode, because hex, Base32 and Base64url are fixed alphabets.
Press Generate to see the entropy of the string.
Private by design. The strings are made in this page with crypto.getRandomValues. Nothing is sent anywhere or stored, and the page does not generate anything until you press Generate.
Free, in your browser. There is no sign-up and no limit, and the page makes no network request when you generate. You can confirm this in your browser’s Network tab.
JavaScript required. With scripts off, the page is readable but cannot generate.
What makes a string random
A random string generator produces text in which each character is picked independently, with equal probability, from a set you choose. This one is free and runs in your browser.
- Strong source. It uses
crypto.getRandomValues, the browser’s cryptographically strong source, neverMath.random. - Your settings. Choose a length from 1 to 256, a character set and up to 50 strings.
- Entropy shown. The tool shows the entropy of the result.
- Private. Nothing is uploaded or stored.
When a random string is the right tool
Use one when a value must be hard to guess, or simply different from every other value:
- Test data and fixtures. Names, IDs and filler text for a database or a test run.
- Identifiers and nonces. A one-time value that must not repeat, such as a
stateornonceparameter or a request ID. - Tokens. Password-reset links, invitation codes, email verification links and similar single-purpose secrets. Store them safely on the server and expire them.
- Salts. Random bytes mixed into a password hash so that equal passwords hash differently.
- Temporary passwords. A first password for someone who must change it at first sign-in.
When it is the wrong tool
- Long-lived secrets. An API key, database password or signing secret that stays in use for months belongs in a secrets manager, which also handles storage, access control and rotation.
- Copied strings. A string copied from a web page tends to end up in a chat message, a ticket or a shell history. For API keys, see the API key generator.
- Cryptographic keys. An encryption key, signing key or TOTP secret has a required size and format. Create it with a key generation tool or the library that will use it, not by pasting text.
- TOTP secrets. The secret behind a TOTP code is normally Base32 and issued by the service that checks it.
- Your own passwords. A random string makes a good password, but a password manager that generates and stores it is safer than a page you visit.
For length and policy rules, read the password policy guide and the NIST password guidelines. A different random password for every site is also the defense against credential stuffing.
Why Math.random is not suitable
Math.random() is intended for games and animation. MDN states this directly (MDN, Math.random, read 2026-10-09): it “does not provide cryptographically secure random numbers” and should not be used “for anything related to security”.
Use the Web Crypto API instead, specifically crypto.getRandomValues(). Sample code that builds IDs from Math.random().toString(36) is not safe for tokens or passwords.
According to MDN, Crypto.getRandomValues, read 2026-10-09, getRandomValues() fills an integer typed array with “cryptographically strong random values”. Further details:
- It throws a
QuotaExceededErrorif the array is larger than 65,536 bytes. - It works in Web Workers.
- It is the only member of the
Cryptointerface that works from an insecure context.
This tool requests 2 KB at a time, well under that limit. If the function is missing, the tool refuses to run instead of falling back to something weaker.
Modulo bias, in two sentences
- The bias. A common shortcut takes a random byte and computes
byte % alphabetSize. Because 256 is not a multiple of 62, the first eight characters of a 62-character alphabet come up 5 times in 256 and the rest only 4, which makes those eight 25 percent more likely. - The fix. This tool avoids that with rejection sampling. It reads a random 32-bit number, discards any value from the incomplete last block at the top of the range, and only then takes the remainder.
- The result. Every character has exactly the same probability.
Alphabets and bits per character
Entropy in bits is the length times log2 of the alphabet size. Each extra character adds the same number of bits, so a larger alphabet needs fewer characters for the same strength.
| Character set | Size | Bits per character | Characters for 64 bits | For 128 bits | For 160 bits |
|---|---|---|---|---|---|
| Digits | 10 | 3.32 | 20 | 39 | 49 |
| Hex (0-9, a-f) | 16 | 4.00 | 16 | 32 | 40 |
| Lowercase letters | 26 | 4.70 | 14 | 28 | 35 |
| Base32 (A-Z, 2-7) | 32 | 5.00 | 13 | 26 | 32 |
| Lowercase and digits | 36 | 5.17 | 13 | 25 | 31 |
| Upper, lower and digits | 62 | 5.95 | 11 | 22 | 27 |
| Base64url | 64 | 6.00 | 11 | 22 | 27 |
| Upper, lower, digits and the 27 symbols the tool offers | 89 | 6.48 | 10 | 20 | 25 |
Each count is the smallest whole number of characters that reaches the figure. The tool’s entropy line does the same calculation for the exact set you chose, after look-alikes are removed.
What the entropy figure does and does not mean
The figure is the logarithm of the number of equally likely strings.
At 128 bits, an attacker who knows the character set and length faces 2^128 possibilities, and a single guess succeeds with probability 2^-128.
The figure has limits:
-
It holds only for the string exactly as generated. It says nothing about a password you edit, choose yourself or trim.
-
It ignores where the string goes. A 256-bit token pasted into a log file is exposed.
-
It cannot tell you how fast an attacker can guess against your system. That depends on rate limits, lockouts and how you store the value.
-
Classes are not forced. The tool does not force each ticked class to appear, because that would reduce the entropy slightly. A 12-character string from a mixed set may contain no digit or symbol.
How long should a token be?
Two primary sources give figures, and they answer different questions.
-
Session IDs. The OWASP Session Management Cheat Sheet (read 2026-10-09) says session identifiers must have at least 64 bits of entropy, from a strong cryptographically secure generator. That is at least 16 hexadecimal characters. It adds that entropy, not length, provides the security.
-
OAuth tokens. RFC 6749, section 10.10 (read 2026-10-09) says the probability of an attacker guessing generated tokens, and other credentials not intended for handling by end users, “MUST be less than or equal to 2^(-128) and SHOULD be less than or equal to 2^(-160)”. From the table above, 128 bits is 22 characters of Base64url or 32 of hex, and 160 bits is 27 of Base64url or 40 of hex.
As a rule of thumb:
- A value no person will type. At least 128 bits, as hex or Base64url.
- A value a person must type, such as a temporary password. A larger alphabet with look-alikes removed and at least 16 characters.
Hex, base32 and base64url
These encodings write bytes as text, so each has a fixed alphabet.
Hex. Hex uses 16 characters.
Base32. Base32 uses A to Z and 2 to 7 (RFC 4648, section 6, read 2026-10-09).
Base64url. Base64url is the Base64 variant for URLs and file names: - replaces +, _ replaces /, and the padding = can be omitted when the length is known (RFC 4648, section 5, read 2026-10-09). A Base64url string is safe in a URL path or query without percent-encoding.
This tool draws each character independently from the alphabet instead of generating bytes and encoding them. The entropy is the same: 6 bits per Base64url character, 5 per Base32 and 4 per hex.
Is this random string generator secure?
crypto.getRandomValues, the browser’s cryptographically strong random source, and never uses Math.random. Rejection sampling keeps every character equally likely. Strings are generated in your browser, and the page makes no network request when you generate.How long should a random string be?
Why not just use Math.random?
crypto.getRandomValues is the browser function designed for this purpose.Can I use a random string as a password?
Why does the tool show entropy in bits?
Does it work offline?
crypto.getRandomValues, the tool declines to generate rather than use a weaker source.Where to go next
Check how strong an existing password is with the password entropy calculator, make a service key with the API key generator, try the TOTP generator, or browse the other free tools.
Sources, all read 2026-10-09: MDN, Crypto.getRandomValues(), MDN, Math.random(), RFC 4648, sections 5 and 6, RFC 6749, section 10.10 and the OWASP Session Management Cheat Sheet.