API Key Generator
Create random API keys and tokens in base64url, hex, base64, alphanumeric, or UUID format. Made in your browser and never sent anywhere.
- Free
- No sign-up
- Offline once loaded
- Never sent or stored
- How it works
Generated keys
How to use the API key generator
- Choose a format. Base64url works almost everywhere.
- Keep 256 bits unless your system needs something else.
- Add a prefix if your keys follow a naming pattern such as sk_live_.
- Copy the key and store it straight into your environment variables or secrets manager.
Formats explained
| Format | Characters used | Length at 256 bits | Safe in URLs as-is |
|---|---|---|---|
| Hex | 0 to 9, a to f | 64 | Yes |
| Base64 | A to Z, a to z, 0 to 9, + and / | 44 (with padding) | No |
| Base64url | A to Z, a to z, 0 to 9, - and _ | 43 | Yes |
| Letters and digits | A to Z, a to z, 0 to 9 | 43 | Yes |
| UUID v4 | Hex digits and hyphens | 36 (122 random bits) | Yes |
Base64 and base64url are defined in RFC 4648; base64url swaps + and / for - and _ so the key can sit in a URL or file name without escaping. The base64url output here drops the trailing = padding. UUIDs are defined in RFC 9562, and a version 4 UUID has 122 random bits because 6 bits are fixed to mark the version and variant. UUIDs here come from the browser's crypto.randomUUID().
Where API keys should live
An API key is a password for a program, so the same rules apply. The OWASP Secrets Management Cheat Sheet recommends keeping secrets in a dedicated secrets manager or injected environment variables, out of source code and version control, with access limited and logged.
- Never paste a key into client-side JavaScript or a mobile app bundle, where anyone can read it.
- Add your .env file to .gitignore before the first commit.
- Use separate keys for development and production so a leaked test key can't touch real data.
- Rotate a key on a schedule your system can handle, and revoke it immediately if it might have been exposed.
Worked example
A developer needs a test key for a webhook. They choose base64url, 256 bits, and the prefix sk_test_. The result is sk_test_ followed by 43 random characters. The prefix makes the key easy to spot in logs and secret scanners, and only the 43 random characters count toward its 256 bits of randomness.
Related tools
Frequently asked questions
Is a UUID secure enough as an API key?
A version 4 UUID carries 122 random bits, which is enough to be unguessable, but it has a fixed, recognizable format. A 256-bit key in hex or base64url is longer and gives more margin, so it is the better default for secrets.
Which format should I use?
Use base64url when the key goes in a URL, header, or environment variable, since it has no characters that need escaping. Use hex when a system only accepts 0 to 9 and a to f. Use UUID only when a system specifically expects one.
How long should an API key be?
256 bits of randomness is the default here and is common practice for secret keys. That is 64 hex characters or 43 base64url characters.
Is the key sent anywhere?
No. The key is generated in your browser with the Web Crypto API and encoded on this page. The tool makes no network requests.
Can I use these keys in production?
Yes, the randomness comes from the browser's cryptographic generator. Treat the key like any other secret: store it in an environment variable or a secrets manager, never commit it to a repository, and rotate it if it might have been exposed.