Use this free random key and token generator to create secure random values for API keys, secrets, session tokens, and test data. Choose a format such as hex, Base64, Base64URL, alphanumeric, numeric, or UUID v4, set the size, and generate one or many values at once. The tool shows the estimated entropy so you can see how strong each key is. Everything runs in your browser and nothing is uploaded or stored.
A good key is long and truly random. The security of a key comes from its entropy, not from how complicated it looks.
How to use the key and token generator
Pick a format, set the options, and generate. A new key is created each time you change an option.
- Format: choose Hex, Base64, Base64URL, Alphanumeric, Numeric, or UUID v4.
- Size: set the number of bytes for Hex, Base64, and Base64URL, or the number of characters for Alphanumeric and Numeric.
- How many: generate up to 20 keys at once, one per line.
- Prefix: add an optional prefix such as "sk_live_" to every key. The prefix does not add to the entropy.
- Copy: copy the keys, or copy a report of the strength details without the keys.
How keys are generated
- Secure randomness: values come from your browser's cryptographically secure random number generator, not from
Math.random. - No bias: for alphanumeric and numeric keys, characters are chosen with rejection sampling so each character is equally likely.
- Entropy: for byte-based formats, entropy is the number of bytes multiplied by 8. For character-based formats, it is the length multiplied by the bits per character. UUID v4 has 122 random bits.
- Rating: Weak, Fair, Strong, or Very strong, based on entropy. For secret keys, 128 bits or more is a common target.
What this tool does and does not do
This tool creates random values. It does not store them, manage or rotate keys, or check how a service expects a key to be formatted. It does not generate key pairs such as RSA or elliptic-curve keys, or signed tokens such as JWTs. Treat every generated value as a secret: keep it out of source control, chat, and email, and store it in a password manager or secrets manager. For production systems, generate keys on your own server or with your platform's key management tools.
Key formats at a glance
| Format | Example | Best for |
|---|---|---|
| Hex | 9f2c4a7e1b0d83c5 | API keys, secrets, and encryption keys. Easy to read and safe in most systems. |
| Base64 | n3xqT7mK2pR9vYb4Lw8Hdg== | Compact keys and secrets. Contains + and / characters, which may need escaping in URLs. |
| Base64URL | n3xqT7mK2pR9vYb4Lw8Hdg | Tokens used in URLs, cookies, and headers. Uses - and _ and has no padding. |
| Alphanumeric | k7Qm2XvR9tLb4WpZ | Readable keys and codes that avoid special characters. |
| Numeric | 482916 | PINs and one-time codes. Short numeric values have low entropy, so limit attempts. |
| UUID v4 | 3b241101-e2bb-4255-8caf-4136c566a962 | Unique identifiers. Use a longer random key when you need a secret. |
If a value must stay secret, make it long. A short key can be guessed no matter how random it is.
Worked examples
A 256-bit secret in hex
Choose Hex and set the size to 32 bytes. The result is 64 hex characters with 256 bits of entropy, which is a common choice for secrets and encryption keys.
A URL-safe token
Choose Base64URL and set the size to 16 bytes. You get a 22-character token with 128 bits of entropy that is safe to place in a URL or cookie. The same 16 bytes in standard Base64 would be 24 characters, including padding.
An API key with a prefix
Choose Alphanumeric, set the length to 32, and add the prefix "sk_live_". The prefix makes keys easy to recognise in logs and secret scanners, while the 32 random characters give about 190 bits of entropy.
A six-digit code
A six-digit numeric code has only about 20 bits of entropy. That is fine for a short-lived one-time code when attempts are limited, but it is not suitable as a secret key.
Common key generation mistakes
- Using a weak random source.
Math.randomand timestamps are predictable. Use a cryptographically secure generator. - Making keys too short. Aim for at least 128 bits for secrets. Short values can be guessed or brute-forced.
- Reusing keys. Use a different key for each service and each environment, such as testing and production.
- Committing keys to source control. Keys in a repository are easy to leak. Use environment variables or a secrets manager.
- Using a UUID as a password. A UUID is designed as an identifier. Use a longer random key for secrets.
- Sharing keys in chat or email. Messages are stored and forwarded. Share secrets through a secure channel.
Frequently asked questions
Is this random key generator free?
Yes. There is no sign-up and no limit on how many keys you generate.
Are my keys sent or stored?
No. Keys are created in your browser and nothing is sent to a server or saved. They disappear when you close or refresh the page, so copy them to a secure place before leaving.
Are the keys truly random?
They come from your browser's cryptographically secure random number generator, which is designed for security uses such as keys and tokens.
How long should a key be?
For secrets and encryption keys, 128 bits is a common minimum and 256 bits is common for high-security uses. That is 16 to 32 bytes, or 32 to 64 hex characters.
What is the difference between Base64 and Base64URL?
Base64URL replaces + and / with - and _ and removes the trailing = padding, so the value is safe to use in URLs, cookies, and file names without escaping.
Can I use these as JWT secrets or encryption keys?
Random hex or Base64 values work well as shared secrets, such as HMAC signing secrets. This tool does not create key pairs or signed tokens. For production, generate and store keys with your platform's key management.