Random String Generator

Draw keys, tokens and nonces from the browser's cryptographic random source, and see how many bits each one actually carries.

Runs on your deviceSecurity & PrivacyWorkingNo account needed

What this tool does

Random String Generator takes every character from crypto.getRandomValues, the browser's route to the operating system's cryptographic random source, and picks it by rejection sampling: a 32-bit sample landing in the leftover tail above the last whole multiple of the alphabet size is thrown away and redrawn rather than folded in with a remainder. That is what keeps a 62-character alphabet evenly represented instead of tilting towards its first few letters. There is no fallback here — a browser that cannot offer crypto.getRandomValues gets an error rather than a lesser generator quietly standing in for it.

Eight character sets are on offer: alphanumeric, hex, base64url, lowercase with digits, letters only, digits only for a PIN, the one labelled printable ASCII, and a custom set you type yourself. Read that ASCII label loosely — the set holds 90 characters, not the 95 that are actually printable, because the space, the two quote marks, the backtick and the backslash are all left out as characters that need escaping somewhere sooner or later. Duplicates in a custom set are removed before anything is drawn, so ABCA counts as three characters and the reported entropy reflects three. The Output setting sits above all of that. Choose one of the three raw-byte modes and both the character set and whatever is in the template box are ignored outright, Length becomes a count of random bytes, and each byte is rendered as hex, base64 or base64url — so 32 there returns 32 bytes, which is 64 hex characters or 43 base64url ones, not a 32-character string.

The input box is optional, and it holds templates rather than data. Each line is a shape: {32} becomes thirty-two random characters, so sk_live_{32} produces a token with a readable prefix, and {8}-{4}-{4}-{12} produces a grouped identifier. Lines beginning with # are ignored, a single placeholder is capped at 1,024 characters, and templates are cycled — three templates with a count of ten give lines four to ten those same three shapes again, in order. A line containing no {n} anywhere has the Length setting's worth of random characters appended to the end, which is worth knowing before you paste in a line of literal text. Where the templates draw different amounts, the summary reports the range instead of pretending one figure covers every line.

The entropy figure counts only the random characters, and that is the honest way to read it. A prefix, and every literal character in a template, adds nothing to the work of guessing a value: sk_live_ is a label, not a secret, and eight digits carry 26.6 bits whatever they are wrapped in. Two further limits matter. Nothing is recorded — no list of issued values is kept, no batch is checked for duplicates, and there is no way to revoke anything, so uniqueness rests on the size of the random space and on your own records. The ceilings are worth knowing too: 500 lines to a run, a Length of at most 256, and 1,024 characters from any one {n} — a template adds its placeholders up, so a line can finish well past what Length alone would ever give you. All of it happens in this browser tab; nothing is uploaded, and the results exist only here until you copy them.

How to use it

  1. Pick the alphabet. Alphanumeric by default. Hex and base64url survive a URL, a config file and a shell argument intact; Digits only gives a PIN; Custom set lets you type your own characters, with repeats discarded.
  2. Set the length and how many. Length runs from 1 to 256, and a single run returns between 1 and 500 lines. Anything in Prefix is prepended to every line and is not counted as random.
  3. Add a template if the shape matters. Write the shape you want, one to a line — api_{40}, or {8}-{4}-{4}-{12} — and start a line with # to comment it out. Leave the box empty to use Prefix and Length on their own.
  4. Switch to raw bytes when a library wants key material. The three byte modes ignore the character set and any template you have written, and treat Length as a byte count, which is the right shape when the documentation asks for 32 bytes rather than 32 characters.
  5. Read the summary before you copy. In character mode it names the alphabet size, how many characters were random, and the bits that follow from the two; in a byte mode, the byte count and its bits. That number, not the look of the string, is what tells you whether the value is strong enough for the job.

Processing & privacy

Runs on your device. Your file is processed directly in this browser.

Common use cases

Minting an API key for a service you run

A readable prefix with a long random tail, such as api_{40}, makes a leaked key identifiable in a log without making it any easier to guess.

Filling in a secret in an environment file

Signing keys and session secrets usually want bytes rather than letters. Base64url output passes through a .env file, a URL and a command line without escaping.

Producing a nonce or a one-off identifier

A short hex or base64url string is enough for a request nonce, a cache-busting suffix, or a temporary filename that must not clash with another.

Building test fixtures that look like production

Templates reproduce the shape of the identifiers your system issues, so a fixture reads convincingly without a live credential sitting in the repository.

Setting a numeric code for a device or a door

Digits only produces a PIN, and the entropy figure makes the cost of a four-digit one plain: 13.3 bits, which is ten thousand guesses.

Questions

Are the generated strings uploaded or logged anywhere?
No. Every value is drawn here in the tab from crypto.getRandomValues, so there is no request to send and nothing to log, and the tool works with the machine offline. Nothing is kept afterwards either: once you navigate away, whatever you copied is the only copy.
Is this random enough for a production secret?
The source is the operating system's cryptographic random generator, reached through the browser's Web Crypto interface, and characters are drawn without modulo bias. What decides the strength is the length and the alphabet you choose, which is exactly why the entropy in bits is reported for every run rather than a colour or a word.
Why is the output longer than the Length I set?
You are in one of the raw-byte modes, where Length counts bytes rather than characters. Thirty-two bytes come out as 64 hex characters or 43 base64url ones, and the character-set menu has no effect in those modes.
Could it produce the same string twice?
It could, and nothing here would notice: no record of past values is kept and no batch is checked for repeats. At 32 alphanumeric characters that is not a practical concern, but 500 four-digit PINs drawn from ten thousand possibilities are almost certain to repeat one, so deduplicate the output whenever the values have to be distinct.
Does the prefix or the literal text in a template add any security?
No. Only the {n} placeholders and the Length setting produce random characters, and the reported bits count only those. A prefix is there so a human or a log parser can recognise the kind of key, not to protect it.
Can it issue a working key for a specific provider?
Only the shape of one. A template reproduces a prefix and a length, but nothing here signs a value or adds the checksum some providers embed, and a real key still has to be issued by that provider so their system knows about it.
How is this different from Password Generator?
Password Generator is built around a value a person types or stores in a manager, including a passphrase mode that assembles words. This one is for machine secrets: long values in bulk, in a fixed shape, and as raw bytes when a library asks for key material instead of characters.

Related tools

  • Protect PDF — Add a password and set permissions on a PDF.
  • Sign PDF — Draw, type or upload a signature and place it on the page.
  • Hash Generator — Compute MD5, SHA-1, SHA-256 and SHA-512 digests.
  • Password Generator — Generate strong passwords with rules you control.
  • Redact PDF — Permanently remove sensitive content, not just cover it.
  • Remove PDF Metadata — Strip identifying metadata before you share a file.