Random String Generator

Choose the characters and the length, or pick Secret key for raw random bytes written as hex or Base64. Every string is made on this device from the browser’s secure random source and never sent anywhere.

How it works

The characters you switch on are joined into one alphabet, each character once. Then each position in the string is filled with a character drawn at random from that alphabet, independently of the others.

The randomness comes from crypto.getRandomValues, the browser’s source for encryption keys. A random byte has 256 values, and most alphabets do not divide 256 evenly, so bytes that would favour some characters are thrown away and drawn again. Every character in your alphabet is exactly as likely as every other.

The Secret key preset skips the alphabet. It takes 16, 32 or 64 random bytes and writes them as hex, Base64 or Base64url, which is the form API keys, signing secrets and encryption keys usually take. The strength line shows the bits of randomness in whatever you have set up.

How to use it

  1. 1 Pick a Preset: Password-like, Letters and digits, Secret key, or Custom.
  2. 2 For a string, switch Lowercase, Uppercase, Digits and Symbols on or off. Turn on Avoid lookalikes to drop I, l, 1, O, 0 and o.
  3. 3 Type extra characters in Also use, or characters a system will not accept in Never use.
  4. 4 Set the Length and How many. For Secret key, pick the Bytes and how to Write as: Hex, Base64 or Base64url.
  5. 5 Check the strength in bits, then copy or download the result. Regenerate makes a fresh set.

Good to know

  • For anything that guards access, aim for at least 128 bits. A 32-byte secret key gives 256.
  • If a system rejects some symbols, add them to Never use rather than switching all symbols off. You keep most of the strength.
  • Base64url is the safest way to write a secret that ends up in a URL, a header or an environment file: it has no +, / or = to escape.
  • Strength in bits assumes the string was made at random, as here. A string you made up yourself is far weaker than its length suggests.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

How strong is a 20-character random string, really?

Strength in a random string comes down to one number: how many equally likely strings could have been made. It is counted in bits, where every extra bit doubles the count. Working it out for a real example shows what the strength line on this page means, and why the way the characters are drawn matters as much as how many there are.

Take the four switches all on: 26 lowercase letters, 26 uppercase, 10 digits and the 16 symbols on this page. That is an alphabet of 78 characters. Each character drawn from it carries log2(78) bits, about 6.29. Twenty of them carry 20 × 6.29, or about 125.7 bits. In other words there are 78^20 possible strings, roughly 2^125.7. An attacker who can test a billion guesses every second would need far longer than the age of the universe to try even a tiny fraction of them.

That figure is only true if every character really is equally likely, and that is where most home-made generators slip. A random byte has 256 values. The obvious way to pick a character is to divide the byte by 78 and use the remainder. But 256 is 3 × 78 with 22 left over, so the byte values 234 to 255 would wrap round onto the first 22 characters of the alphabet. Those 22 would come up with 4 chances in 256, the other 56 with only 3. The first 22 characters would be a third more likely than the rest, and a careful attacker would guess them first. This page throws away any byte of 234 or more and draws again. It wastes about 9% of the bytes, which costs nothing you could notice, and the 125.7 bits are real.

The Secret key preset works the other way round. It does not pick characters at all: it takes random bytes and writes them down. Thirty-two bytes are 256 bits, because every byte is 8 bits and every value is used. Written as hex, two characters per byte, that is 64 characters. Written as Base64, four characters for every three bytes, it is 43 characters plus one = of padding. Base64url uses - and _ instead of + and / and drops the padding, so it is 43 characters that can go anywhere, including a URL. All three are the same 256-bit secret; only the spelling differs. Sixteen bytes give 128 bits, which is enough for most tokens; sixty-four bytes give 512, which suits HMAC keys for SHA-512.

A few limits are worth stating plainly. The bits measure how hard the string is to guess, nothing else. They do not protect a secret you paste into a chat, commit to a repository or leave in a log. Avoid lookalikes and Never use both shrink the alphabet, and the strength line goes down with them, so add a character or two of length to make up for it. And the strength assumes the browser’s random source is sound, which crypto.getRandomValues is in every modern browser: it draws from the operating system’s cryptographic generator. Everything happens on this page, so the string exists only on your screen until you copy it.

Frequently asked questions

Where did the Secret Generator go?

It is this page. /secret-generator now opens here, because a secret key is simply random bytes written as text. The Secret key preset gives you 16, 32 or 64 bytes as hex, Base64 or Base64url.

How long should a random string be?

Look at the bits, not the length. 128 bits is plenty for a token or an API key. With letters, digits and the 16 symbols, that is 21 characters; with lowercase and digits only, it is 25.

Is this a good password generator?

It makes strong random strings, and Password-like is a sensible start. A password manager is still the best place to make and keep passwords, because it also remembers them for you.

Which symbols are used?

The Symbols switch adds ! # $ % & * + - . : = ? @ ^ _ ~. Quotes, backslashes, brackets and spaces are left out because they break shell commands, JSON and config files. Add any of them yourself with Also use.

Is anything sent to a server?

No. The strings are made in your browser with crypto.getRandomValues, and the page works offline once it has loaded.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.