Random alphanumeric string
The default: uppercase letters, lowercase letters and numbers (A-Z, a-z, 0-9), 62 characters in total. It works almost everywhere, in URLs, file names, databases and config files, without any escaping.
Need a random string for an API key, a JWT secret, a voucher code or test data? Pick the length and the characters and copy the result. One string, or up to 1,000 at once.
Strings are created right in your browser with a secure random generator and are never sent anywhere.
Result
The longer a string is and the more kinds of characters it uses, the harder it is to guess. These settings work for the most common uses.
| Use | Settings | Randomness |
|---|---|---|
| JWT secret (HS256) | 43 letters and numbers, or 64 hex | 256 bits |
| API key or access token | 32 letters and numbers | 190 bits |
| Session ID or CSRF token | 32 letters and numbers | 190 bits |
| Voucher or invite code | 8 to 12 uppercase letters and numbers, without look-alikes | 40 to 60 bits |
| File name or cache key | 16 lowercase letters and numbers | 82 bits |
For account passwords, the Password Generator is the better choice. It also creates passphrases and PINs and shows how strong each password is.
Looking for random words or sentences instead? Use the Lorem Ipsum generator.
The generator starts with letters and numbers. Switch characters on or off depending on where the string will be used.
The default: uppercase letters, lowercase letters and numbers (A-Z, a-z, 0-9), 62 characters in total. It works almost everywhere, in URLs, file names, databases and config files, without any escaping.
Turn on symbols to add !#$%&()*+,-./:;<=>?@[]^_{}~. Each character then has more options, so the same length gives more bits of randomness. Quotes, backslashes, backticks, pipes and spaces are left out on purpose, because they most often break code, config files and command lines.
Turn off the groups you do not need. Keep only numbers for a numeric code or a test ID, only letters for a code without digits, or uppercase and numbers for a code that is easy to read out loud.
Turn on hex for the digits 0-9 and the letters a-f. Each hex character carries 4 bits, so 32 hex characters equal 16 random bytes and 64 equal 32 bytes. Many systems expect keys, tokens and IDs in this format.
For voucher codes, invite codes and anything people type in or read from paper, turn on leave out look-alike characters. 0 and O, or 1, l and I then never appear, so nobody mixes them up.
Inside a script or an app, use the secure random functions your language already has. Each example creates 32 characters or a secret from 32 random bytes.
import secrets, string
alphabet = string.ascii_letters + string.digits
print(''.join(secrets.choice(alphabet) for _ in range(32)))python3 -c "import secrets; print(secrets.token_urlsafe(32))"const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const limit = 2 ** 32 - (2 ** 32 % alphabet.length);
let value = '';
while (value.length < 32) {
const [n] = crypto.getRandomValues(new Uint32Array(1));
if (n < limit) value += alphabet[n % alphabet.length];
}
console.log(value);node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"echo bin2hex(random_bytes(16));openssl rand -hex 32
LC_ALL=C tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 32; echoMore generators for test data, codes and placeholder content.
Frequently asked questions