← Tools
Utilities

Random String Generator

Generate cryptographically secure random strings for API keys, passwords, and tokens.

Generated Strings62 possible chars
Configure options and click Generate

What is cryptographically secure random strings?

A CSPRNG produces bits that are unsuitable for an attacker to predict. In browsers, crypto.getRandomValues draws from the platform CSPRNG. That is the correct source for API keys, session tokens, and password-like strings. Math.random is not.

This generator fills a Uint8Array with crypto.getRandomValues — the Web Crypto CSPRNG — then maps each byte into a character set you selected. It does not use Math.random. Character sets are uppercase A–Z (26), lowercase a–z (26), digits 0–9 (10), and the symbol string !@#$%^&*()-_=+[]{}|;:,.<>? (26). Enabling all four yields 88 symbols. Length defaults to 32 (range 4–128); count defaults to 5 (range 1–20). Generate draws a fresh batch; each row has its own copy control, and Copy All joins rows with newlines. Nothing is sent to a server, which matters if you are minting API keys. For a password with a strength meter and passphrase words, use Password Generator. For a time-sortable id, use UUID v7. Mapping bytes with modulo charset length can slightly bias symbols when 256 is not a multiple of the set size; for ordinary API keys that bias is negligible, but it is not a full rejection-sampling construction.

When to use this tool

  • API keys and secrets — Length 32–64 with mixed case and digits is a common pattern. Add symbols only if the receiving API allows them.
  • Test fixtures — Generate several strings at once (count up to 20) for seed data. They are independent draws, not a sequence.
  • Short codes — Digits only at length 8 produces a string matching [0-9]{8}. It is not a one-time-password algorithm (no TOTP).
  • Hash afterward — If you need a digest of a generated secret, copy it into Hash Generator. Do not treat the random string itself as a hash. Hash Generator

How to use the Random String Generator

Step 1

Set length and count

Length is characters per string (4–128). Count is how many strings to emit (1–20).

Step 2

Choose character sets

Upper, lower, numbers, and symbols can be mixed. At least one set must be on or Generate stays disabled. The panel header shows how many distinct characters are in the combined set (10, 36, 62, 88, …).

Step 3

Generate

Each click draws new bytes. Previous rows are replaced, not appended. Clear removes the list.

Step 4

Copy one or all

Copy on a row copies that string. Copy All copies every string separated by newlines.

Worked examples

Digits only, length 8

Input
length=8, numbers on, upper/lower/symbols off
Output
Eight characters from 0123456789 (charset length 10). Shape: /^[0-9]{8}$/

The exact digits change every Generate click because each byte comes from crypto.getRandomValues.

Alphanumeric token, length 32

Input
length=32, upper+lower+numbers, symbols off
Output
32 characters from A–Z, a–z, 0–9 (62-character set). Header reads “62 possible chars”.

Full set including symbols

Input
length=16, all four sets on
Output
16 characters from an 88-character set (26+26+10+26). Symbols used: !@#$%^&*()-_=+[]{}|;:,.<>?

Tips

  • Confirm the consumer allows symbols before enabling the symbols set — some APIs reject punctuation.
  • Confused characters such as 0/O and 1/l/I are not filtered; regenerate if a human has to read the string aloud.
  • Copy All is handy for pasting into a .env example file, one secret per line.
  • This is not a password manager; store secrets in your team’s vault after you copy them.

Frequently Asked Questions

Are these strings cryptographically secure?

Bytes come from crypto.getRandomValues, not Math.random. That is appropriate for API keys and tokens generated on your machine. Mapping each byte with modulo charset length can introduce a small bias when the charset length does not divide 256; for typical key lengths this is rarely a practical issue.

What length should I use?

32–64 characters for API keys, 16–32 for passwords if you are not using Password Generator, 64 or more for high-value secrets. Short codes (8–12) are for non-secret identifiers only.

Why is Generate disabled?

Every character-set checkbox is off, so the charset is empty. Turn at least one set back on.

Is generation uploaded or logged?

No. Web Crypto runs in the browser. Generated keys never leave the device unless you copy them somewhere else.

How is this different from Password Generator or UUID?

Password Generator adds a strength meter and passphrase words. UUID Generator / UUID v7 emit standardized identifiers, not arbitrary charset strings.