API Key Generator
Generate random API keys and secrets with an optional prefix such as sk_test_. Choose base64url, alphanumeric, base32 or hex, 8 to 96 characters, up to 100 keys.
Generating…
Generated in your browser and not sent to our server.
Presets copy a prefix and length convention. The keys are random strings and will not work with any third-party service.
01 · Definition
What is an API key?
An API key is a long random string that a client sends with each request so a service can identify and authorise it. Its security comes from being unguessable: a key with 128 or more bits of entropy from a cryptographic random source cannot be found by trial. Many services add a fixed prefix so leaked keys are easy to recognise.
02 · Overview
How the API Key Generator works
Generates random keys and secret tokens with crypto.getRandomValues and rejection sampling. Choose a character set (base64url, alphanumeric, base32 or hex), 8 to 96 random characters, an optional prefix such as sk_test_ or whsec_, and 1 to 100 keys. The entropy shown is calculated from the key on screen and does not count the prefix. Presets copy common prefix and length conventions; the keys are random strings and are not valid credentials for any service. Keys are generated in your browser and are not sent to our server.
03 · Guide
How long should an API key be?
Entropy is the number of random characters times the bits each character carries. The prefix is fixed text and adds nothing. 128 bits is a common minimum for a secret key and 256 bits is a common choice for signing secrets; RFC 7518 requires an HS256 key of at least 256 bits.
base32 here is the RFC 4648 alphabet, A to Z and 2 to 7, which leaves out the digits 0, 1, 8 and 9 and survives case-insensitive systems.
| Character set | Characters | Bits per character | For 128 bits | For 256 bits |
|---|---|---|---|---|
| hex | 16 | 4 | 32 | 64 |
| base32 | 32 | 5 | 26 | 52 |
| alphanumeric | 62 | 5.95 | 22 | 43 |
| base64url | 64 | 6 | 22 | 43 |
04 · Use cases
When to use the API Key Generator
- 01
Create a key format for your own API, with a prefix your team can recognise
- 02
Generate a 256-bit secret for signing webhooks or HS256 JWTs
- 03
Seed a test database with up to 100 distinct keys
- 04
Make a random bearer token for local development
05 · Examples
API Key Generator examples
Prefix sk_test_, base64url, 32 characters
ex 01sk_test_2HyHHSCJ_Y1BEOnaGz5YD6zRqzqijRaN
The random part has 192 bits. The prefix is a naming convention, not a working key for any provider.
No prefix, hex, 64 characters
ex 029ad8ba26d6a4c322f48f7447ec95281d505e46fa53fc89bbc33ad42ab671e893
256 bits, suitable as an HS256 JWT secret or an HMAC key.
Prefix whsec_, hex, 64 characters
ex 03whsec_1d7a9e02bfbbaf852269928a6c6242808b7761806af37ad861d6321b5a457d5b
A 256-bit webhook signing secret with a recognisable prefix.
No prefix, base32, 26 characters
ex 04K42PN3AFTAYRCPHKYOR3MD6VGV
130 bits using only A to Z and 2 to 7, for keys that are read aloud or typed.
06 · FAQ
API Key: frequently asked questions
How much entropy does an API key need?
Why use a prefix?
Are these keys safe to use in production?
Will a preset key work with Stripe or GitHub?
How should I store an API key on the server?
Which character set should I choose?
07 · Reference
Specs and further reading
These are the primary sources this tool follows. Where a specification defines the behaviour, we link the specification, not a summary of it.
- Secrets Management Cheat Sheet
OWASP. How secrets such as API keys should be stored, rotated and revoked.
- RFC 4648: The Base16, Base32, and Base64 Data Encodings
IETF. Defines the hex, base32 and URL-safe base64 alphabets the character sets are taken from.
- RFC 7518: JSON Web Algorithms (JWA)
IETF. Section 3.2 requires an HMAC key at least as long as the hash output: 256 bits for HS256.
- Crypto.getRandomValues()
MDN Web Docs. The randomness source for every generated key.
08 · More
Tools that pair with API Key
Password Generator
Generate strong random passwords or passphrases from the EFF wordlist. Set the length and character types, see the entropy, and make up to 100 at once.
JWT Decoder & Encoder
Decode a JWT to read its header and claims, verify its signature with a secret or public key, and sign new tokens with HS, RS, PS and ES algorithms.
Hash Generator
Hash text or a file with MD5, SHA-1, SHA-256 or SHA-512, and compare it with an expected checksum. Create and check bcrypt password hashes.
UUID Generator
Generate UUID v4, v7 or v1, one at a time or up to 1,000. Output as standard, uppercase, braces (GUID), no hyphens, URN or Base64, and decode any UUID you paste.
PIN Generator
Generate random 4, 6 or 8-digit PINs. Optional filters leave out obvious patterns like 1234 and 0000, and PINs that read as dates or years.