Developer

Random String Generator

Generate random strings with a chosen length and character set for tokens, test data, keys and identifiers.

Last reviewed by the Radiatus Cloud team

Need this built for your product?

We design, build & host secure software & APIs.

Talk to an engineer

Entropy, not length, is what matters

The strength of a random string is the number of possible values, which is the character set size raised to the length. A 16-character string from a 62-character alphanumeric set has about 95 bits of entropy; the same length from a 16-character hex set has 64. Doubling the alphabet adds one bit per character, while adding one character adds log2 of the alphabet size. Length is the more effective lever, which is why long strings from a small safe alphabet often beat short strings from an exotic one.

Choose the alphabet for where the string will travel

A string that will appear in a URL should avoid characters needing percent-encoding. One that might land in a filename should avoid slashes, colons and characters Windows rejects. One that a human might read aloud or retype should exclude lookalikes: l, 1, I, 0 and O. Base58, which is base62 minus those four, exists precisely for that reason and is what Bitcoin addresses use.

Unbiased sampling

Picking a character by taking a random byte modulo the alphabet size skews the distribution unless the alphabet size divides 256 evenly, which for 62 it does not. The correct approach rejects and redraws values that would introduce bias. The effect is small but real, and it matters for anything security-relevant.

Tokens are not passwords

A random string used as a session token, API key or reset link needs to be unguessable, which this provides. It also needs the surrounding handling: transmitted only over TLS, stored hashed rather than in plaintext, given an expiry, and made revocable. A strong token in a system with none of those properties is not secure.

Test data

Random strings make better fixtures than repeated placeholder text because they vary in length and content, which is what exposes truncation, encoding and layout bugs. Include the extremes deliberately: an empty string, a single character, and something far longer than the field expects.

Generated locally

Values come from the browser's cryptographic random source and are never transmitted.

Related tools

  • JSON Formatter — Format and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
  • JSON Validator — Validate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
  • Regex Tester — Test regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.
  • HTML Minifier — Minify HTML by removing comments and redundant whitespace, without breaking inline elements or pre blocks. Runs entirely in your browser.

Frequently Asked Questions

How long should a random token be?

Aim for entropy rather than a character count. Around 128 bits is the usual target for a security token, which is 22 characters of base62 or 32 hex characters.

Which character set should I use?

One suited to where the string will travel. Avoid URL-unsafe characters in URLs, filesystem-hostile ones in filenames, and lookalikes such as l, 1, I, 0 and O in anything a human retypes.

What is sampling bias in a random string?

Taking a random byte modulo the alphabet size skews the distribution when the size does not divide 256 evenly, as 62 does not. Correct generators reject and redraw rather than taking the remainder.

Is a random string enough to secure an API?

No. The token also needs TLS in transit, hashed storage, an expiry and a revocation path. A strong token in a system lacking those is not secure.

Why use random strings as test data?

Because they vary in length and content, which exposes truncation, encoding and layout bugs that uniform placeholder text hides. Include an empty string and an over-long value deliberately.

Privacy & Security

All processing happens locally in your browser — nothing is uploaded.

Data: None
Client-side-Side
Active
v1.0

How to Use

Pick a character set or enter your own, set length and count, then Generate.

Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.