Tools / Random String / API Key Generator

Random String / API Key Generator.

Generate random strings, API keys and tokens with custom length, character set, hex or Base64 format and prefix.

Runs in your browser

Characters for the character format; bytes of randomness for hex and Base64.

Ctrl/⌘ + Enter to run · Ctrl/⌘ + Shift + C to copy the result

Result
Strings
Strength

About Random String / API Key Generator

This generator produces random strings for API keys, client secrets, session tokens, invitation codes and test data. Pick a length and the character groups you want — uppercase, lowercase, digits and symbols — or type your own alphabet, for example ABCDEFGHJKMNPQRSTVWXYZ23456789 for codes people read aloud. A prefix such as sk_live_ or ghp_ is prepended unchanged, which makes leaked keys easy to recognise and lets secret scanners detect them. Switch the format to hex, Base64 or Base64URL to get the equivalent of openssl rand -hex 32: the length then means bytes of randomness, so 32 bytes become 64 hex characters or 43 Base64URL characters. Every character is drawn with your browser's cryptographic random generator and rejection sampling, so there is no modulo bias that would make some characters more likely than others. The Strength panel shows the entropy in bits; 128 bits or more is the usual target for secrets that are checked online, and 32 random alphanumeric characters give about 190 bits. Common mistakes are using Math.random or a timestamp for tokens, choosing a short code without rate limiting, and putting symbols into keys that end up in URLs or shell commands without escaping — use Base64URL or alphanumeric characters there. The page is marked sensitive: generated values are never written to the address bar or sent to a server.

How to Use

  1. Set the length, how many strings you need and the format.
  2. Choose character groups or enter custom characters, and add an optional prefix.
  3. Press Run to generate a fresh batch, then copy the strings.

Frequently Asked Questions

How long should an API key be?

Aim for at least 128 bits of entropy. That is 22 alphanumeric characters, 32 hex characters or 16 random bytes. Longer keys cost nothing, so 32 characters or 32 bytes are a sensible default.

What is the difference between the character and hex formats?

The character format picks each character from your chosen set. Hex and Base64 encode random bytes, so the length field counts bytes, and the result is 2× (hex) or about 1.33× (Base64) longer.

Why exclude look-alike characters?

Characters such as I, l, 1, O and 0 are easy to confuse when a code is read from a screen or printed. Excluding them slightly reduces entropy per character, which the strength panel accounts for.

Are the generated keys stored or sent anywhere?

No. They are generated in your browser with crypto.getRandomValues, never leave the page and are not saved in the URL or history.

Related Tools