Resell services with the EthicalSMM API

Random String Generator

Generate cryptographically secure random strings of any length from letters, digits, hex, URL-safe or your own character set.

Was this tool helpful?

Thanks for the feedback!

This tool generates random strings from a character set you choose, such as letters and digits, hex or URL-safe characters. It is built for developers who need API keys, tokens, test data, coupon codes or temporary passwords, and it shows how many bits of entropy each string has so you can judge whether it is long enough.

The fields

  • Length (characters): from 1 to 1024. The default is 16.
  • How many strings: from 1 to 500 at once, one per line. The default is 5.
  • Characters: the set to draw from. The options are letters and digits (62 characters), letters only (52), lowercase and digits (36), uppercase and digits (36), digits only (10), hex 0–9 and a–f (16), URL-safe letters, digits, - and _ (64), no look-alikes (56) and letters, digits and symbols (85).
  • Or use your own characters (overrides the list), optional: type any characters, for example ABCDEFGHJK23456789 for voucher codes. Duplicates are removed, so AABBC becomes a set of three.

The no look-alikes set leaves out 0, O, 1, l and I, which makes codes easier to read out over the phone or copy from a printed slip. The URL-safe set matches the alphabet used by Base64url, so its strings can go into links and file names without escaping.

How the strings are made

Each character is picked with crypto.getRandomValues, the browser's cryptographically secure random number generator. Math.random is not used, because its output can be predicted and is not meant for security.

The tool also avoids modulo bias. A random 32-bit number can take 4,294,967,296 values, which does not divide evenly by, say, 62. Taking the remainder directly would make a few characters very slightly more likely than others. The tool uses rejection sampling instead: it throws away the small top slice of values that would cause the imbalance and draws again, so every character in the set has exactly the same chance.

All of this happens in your browser. Nothing is sent to a server or saved, so the strings are seen only by you.

Entropy: how strong is a string?

The tool reports Entropy per string using:

entropy bits = length × log₂(character set size)

Each extra bit doubles the number of possible strings. The figures below are what the tool shows:

SettingsSet sizeEntropy
6 digits1019.9 bits
8 lowercase and digits3641.4 bits
12 no look-alikes5669.7 bits
16 letters and digits6295.3 bits
21 URL-safe64126 bits
32 hex16128 bits
20 letters, digits and symbols85128.2 bits

A 6-digit code has about a million possibilities, which is fine for an OTP that expires in minutes and allows only a few tries, but far too weak for anything that can be guessed offline. For API keys, session tokens and password reset links, aim for at least 128 bits. A 32-character hex string or a 22-character URL-safe string gets you there.

The entropy figure is only accurate because the characters are chosen at random. A string you make up yourself, even with the same length and symbols, has far less real entropy.

Picking the right set

  • Database IDs or file names: lowercase and digits, or hex, avoid case-sensitivity problems.
  • Tokens in URLs or cookies: URL-safe.
  • Codes people type by hand: no look-alikes, or a custom set without vowels so you do not spell real words by accident.
  • Symbols give more bits per character, but some systems reject characters such as quotes, brackets or &. Test before you rely on them.

Limits and messages

A length outside 1 to 1024, or a decimal, gives "Length must be a whole number from 1 to 1024." More than 500 strings gives "Generate between 1 and 500 strings at a time." A custom set with only one distinct character, like aaaa, gives "The custom character set needs at least two different characters."

For login passwords with rules about required character types, the password generator is a better fit. For standard identifiers in the 8-4-4-4-12 format, use the UUID generator.

Frequently asked questions

Are these random strings secure enough for API keys?
Yes, if they are long enough. Each character comes from crypto.getRandomValues with rejection sampling, so aim for about 128 bits of entropy, such as 32 hex characters or 22 URL-safe characters.
How is entropy calculated?
The tool multiplies the length by log base 2 of the character set size. A 16-character string from the 62 letters and digits has 16 × 5.954 = 95.3 bits.
What does no look-alikes mean?
It leaves out characters that are easy to confuse, namely 0, O, 1, l and I. That leaves 56 characters and makes codes easier to read and type.
Is anything I generate stored or sent anywhere?
No. The strings are created in your browser and are not uploaded or saved by the site.
Can I use my own set of characters?
Yes. Type them in the custom field and they replace the list choice. Repeated characters are removed, and you need at least two different ones.
How many random strings can I generate at once?
Up to 500 strings, each up to 1024 characters long. They appear one per line with a button to copy them all.

Related guides

Related tools

People also used

Embed this tool on your site

Paste it into any blog or website. Free, with a credit link.