Developer friendly • Private

Random String Generator

Generate random strings, tokens and IDs of any length from 1 to 512 characters. Choose alphanumeric, hexadecimal, any mix of character types, or your own custom character set.

Random string generator

Generating…
Strength: - Entropy: ~0 bits
Mode
1 – 512
Character pool

62 unique characters

A random string generator for developers

Many everyday development tasks need values that are unpredictable: secrets for signing cookies, tokens for password-reset links, seeds for test data, or codes that customers type in. Writing a quick script with a non-cryptographic random function is a common source of security bugs. This tool gives you correctly generated values instantly, with the entropy spelled out.

Choosing a format

ModeCharactersBits per characterBest for
AlphanumericA–Z, a–z, 0–9 (62)≈ 5.95Tokens, IDs, URL-safe values
Hexadecimal0–9, a–f (16)4.00Keys, hashes, colour-safe IDs
All typesLetters, digits, 32 symbols (94)≈ 6.55Secrets stored in config files
Custom setWhatever you enterlog2(set size)Readable codes, special formats

The default custom set, ABCDEFGHJKMNPQRSTUVWXYZ23456789, leaves out characters that are easy to confuse (0/O, 1/I/L), which makes it a good choice for codes that people read aloud or type from a printout.

How it works

Each character is selected independently from the character pool using crypto.getRandomValues() and rejection sampling, so there is no modulo bias and every character in the pool is exactly equally likely. Entropy is length × log2(pool size). Read more on the How It Works page.

Security tips

  • Store secrets in environment variables or a secrets manager, never in source control.
  • Rotate tokens if they may have been exposed, for example in logs or screenshots.
  • Hash long-lived tokens before storing them in a database, just as you would passwords.
  • Need a human password instead? Use the password generator or passphrase generator.
FAQ

Random string generator FAQ

What can I use random strings for?

Typical uses include API keys and access tokens, session or CSRF secrets, database seed data, invite and coupon codes, unique filenames, test fixtures, salts and nonces, and identifiers that must be hard to guess. Use hexadecimal when a system expects hex, and alphanumeric when the value must be safe in URLs and filenames.

How long should a random token be?

For secrets such as API keys or session tokens, aim for at least 128 bits of entropy. That is 32 hexadecimal characters, or 22 alphanumeric characters (22 × 5.95 ≈ 131 bits). For 256 bits use 64 hex or 43 alphanumeric characters. The entropy readout above the controls shows the exact value for your settings.

What is the difference between the modes?

  • Alphanumeric: A–Z, a–z and 0–9 (62 characters, about 5.95 bits each).
  • Hexadecimal: 0–9 and a–f, or A–F if you choose uppercase (16 characters, exactly 4 bits each).
  • Custom types: any combination of uppercase, lowercase, numbers and symbols.
  • Custom character set: type exactly the characters you want; duplicates are removed so each character is equally likely.

Are these strings safe to use as cryptographic keys?

The characters come from crypto.getRandomValues(), a cryptographically secure random number generator, and are selected without bias. That makes them suitable as secrets. For keys that protect production systems, it is still best practice to generate them inside your own infrastructure or secrets manager so they are never displayed on a screen or copied through a clipboard.

Can I generate many strings at once?

Yes. Set “How many” to any number up to 50. Each string is generated independently, and you can copy them one at a time or all together, one per line.

Can I use emoji or non-Latin characters in a custom set?

Yes. Custom character sets are split into full Unicode characters, so emoji and accented letters are handled correctly. Keep in mind that many systems only accept plain ASCII in passwords and tokens.