Random String Generator
Generate cryptographically secure random strings, tokens and raw bytes — on a page that stores nothing and sends nothing.
Download writes these values to your disk as a plain-text file.
Press ? for shortcuts · Values are produced in memory and never written to storage or sent anywhere.
This page loads no third-party code — no ads, no trackers, no analytics. Verify in your Network tab.
Do it offline:$ openssl rand -hex 32
How to use it
- Choose the output: characters, or raw bytes in an encoding. Each mode has its own controls, and switching redraws the batch.
- For a string, pick a preset — alphanumeric, hex or Base64URL — or choose Custom and type an alphabet. For bytes, set the byte count and encoding.
- Set the length and how many values you want, up to a thousand. Any change regenerates the batch, since each value is atomic.
- Press Generate, or ⌘/Ctrl + Enter, for a fresh draw — old values go by design, but settings stay put.
- Copy one value, copy all, or Download .txt, one per line. A shared link carries settings only.
Pick a character set, a length and a count, then generate: random strings drawn on your device from the browser's cryptographic generator and rejection-sampled so no character is favored. Ask for characters — alphanumeric, hex, Base64URL or a custom alphabet — or raw bytes as hex or Base64. Make one or a thousand; nothing is stored or sent.
How it works
To avoid bias, the generator reads a uniform 32-bit number and keeps it only when it is below limit = 2³² − (2³² mod n), where n is the set size; the survivor maps modulo n to an index. Whether any number is dropped depends on n: a power-of-two set — hex at 16, Base64URL at 64 — discards nothing, while the 62-character alphanumeric set rejects exactly 4 of every 2³² numbers.
String mode and bytes mode differ at the root. In string mode each position is an independent draw from your alphabet, so a Base64URL string is just a random sequence over the 64 URL-safe characters. In bytes mode the tool encodes whole random bytes, so Base64URL is then a real encoding a decoder reverses. Bytes are already uniform, so nothing is rejected — sixteen bytes carry a flat 128 bits.
Examples
alnum · length 32 · count 1WkdhVGOeZpmHxsX22R2SHcSCJAZJA78GA 32-character token from the 62-symbol alphanumeric set: 32 × log₂(62) = 190.5 bits, with 4 of every 2³² draws rejected. Being random, it is illustrative — verified by shape, not by bytes.
bytes · 16 bytes · hexd3dbc3b6d3607a609d8ac11f3fbb87fdSixteen random bytes as hexadecimal: two per byte give 32 characters and a flat 128 bits, and since bytes are already uniform, nothing is discarded — the usual shape for tokens and salts.
custom · banana · length 32ananbnaaabaaaabnnnbababnbnnnnabnThe word banana as a custom set folds to three distinct letters — b, a, n — three duplicates counted once, a pool of three: 32 × log₂(3) = 50.7 bits. Three does not divide 2³² evenly, so one draw in 2³² is rejected.
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
Hex the string versus hex the bytes
Two outputs can read as hexadecimal yet differ: the hex preset draws from 0–9 a–f, so an odd length is fine, while bytes in hex are two per byte and always even.
When nothing is thrown away
Rejection only bites when the set size does not divide 2³² evenly. Hex at 16 and Base64URL at 64 are powers of two and discard nothing; the 62-symbol set redraws a tiny fraction.
How a custom set is tidied
A custom alphabet is read by code point in first-appearance order, each distinct one kept once and repeats reported. An emoji or astral character is one symbol spanning two UTF-16 units; whitespace is kept, not refused.
Treat the output like a secret
Output is a token, key, salt or nonce, treated as sensitive: the value pane resists locale reordering, and Copy takes the string itself. A clipboard may sync a copy; Download writes plain text to disk.
Nothing is kept between visits
This tool saves no state — no preferences, no last batch, nothing in session or local storage. A link carries settings only; a credential-shaped custom set is flagged, never stored.
Common errors
The custom character set is empty — add characters to draw from.- String mode is on a custom alphabet, but after duplicates are removed nothing is left to draw from — add a character, or pick a preset.
Length must be a whole number between 1 and 1,024.- The length must be a whole number in range; a fraction, a negative or a value past 1,024 is refused, not rounded.
Byte length must be a whole number between 1 and 1,024.- Same rule for bytes: the byte count runs 1 to 1,024, and anything else stops the draw instead of clamping.
Count must be a whole number between 1 and 1,000.- Up to a thousand values come at once; beyond that, or below one, the batch is refused, not quietly trimmed.
FAQ
Are these values safe to use as API keys or tokens?
Yes, with care. Each value comes from crypto.getRandomValues, the source a server uses; sixteen random bytes carry 128 bits, ample for a key. Storing and sending the secret is then on you.
What is the difference between a character set and raw bytes?
A character set draws visible symbols one by one, so the result is exactly the length you set. Raw bytes are eight-bit values printed as hex or Base64, so length follows the encoding; use bytes for bits, a string for characters.
Is the output really unbiased?
That is what rejection sampling buys. A plain number-mod-size shortcut favors the first few symbols when the size does not divide the range evenly. Instead a draw is kept only inside the largest exact multiple, so every symbol is equally likely.
Keyboard shortcuts
- ⌘/Ctrl + Enter
- Regenerate — trade the whole batch for a fresh random draw.
- ⌘/Ctrl + S
- Download the batch as a .txt file; in the browser this shortcut saves the file, not the web page.
- ⌘/Ctrl + C
- When focus is in the tool and nothing is highlighted, copy all values at once; highlight text first and it copies only that.
- ⌘/Ctrl + Shift + C
- Copy the whole batch even while a text selection is active.
- ? or ⌘/Ctrl + /
- Open the in-tool shortcut help.