API Key Generator
An API key is a bearer secret: whoever presents it is the caller. It needs CSPRNG bytes, not a company name plus a year. Generate a key here, store the hash (or a vault copy) on the server, and show the plaintext once. Prefixes like sk_live_ help scanners and humans, but they do not add secrecy.
What the API key generator is for
API keys authenticate machine-to-machine calls. Because no human types them, they should be long and fully random — yet they are too often short, sequential, or derived from something guessable.
A weak key is worse than a weak password: it usually carries broad permissions, is rarely rotated, and its misuse is easy to overlook in server logs.
Common uses
- Issuing keys for a new API integration
- Rotating a key after a suspected leak or a staff departure
- Creating separate keys per environment so staging cannot touch production
- Generating service tokens for internal jobs
What the output means in the real world
The token is the secret you paste into a server environment variable or a secret manager, not into the mobile app binary. Never commit it, never email it, never put it in a support ZIP. If it appeared in a screenshot or a CI log, revoke it in the issuing product and generate a replacement. Clients should send it in a header, not a query string.
How this fits into real work
GitHub, AWS, and Slack all publish documented prefix formats so secret scanning can revoke leaked keys automatically. Add a stable prefix of your own so grep and scanners can find yours.
Keys in frontend bundles are public. If the browser must call you, use short-lived user tokens (OAuth, OIDC), not a long-lived server key shipped in JavaScript.
Rotation is an operational drill, not a theory. Issue two keys, move traffic, then disable the old one. A generator that only mints strings does not replace an inventory of where each key is deployed.
How to use this tool
- Choose a format — hex, Base64URL, or a prefixed key.
- Pick a length of at least 32 bytes for anything guarding real data.
- Add a prefix identifying the environment, such as live_ or test_, so a key's scope is obvious at a glance.
- Store the key in a secrets manager, and record only a hash of it in your database.
Tips
- Store a hash of the key, never the key itself, exactly as you would a password.
- Show the key once at creation and never again — that forces safe storage by the recipient.
- Prefixes make automated leak scanning possible; GitHub can detect and alert on a recognisable format.
Privacy & how it works
Everything happens inside your browser. The values you type are held in page memory only, are never sent to a server, and disappear when you close the tab. You can confirm this in your browser's network tab: the only request a tool makes is one that names the tool for a usage count, with nothing you typed in it. The tools also work with the internet disconnected. Randomness comes from crypto.getRandomValues(), the browser's cryptographically secure generator, not Math.random(). Math.random() is seeded predictably and must never be used for anything security-related, because an attacker who learns part of the sequence can reconstruct the rest.
Frequently asked questions
- How long should an API key be?
- At least 32 random bytes, which is 64 hex characters or about 43 Base64 characters. That is far beyond brute-force reach.
- Should API keys expire?
- Yes where practical. Expiry limits the damage from a leak that nobody noticed, and it forces rotation to be a tested, routine process.
- How should I store API keys?
- In a secrets manager or environment variables — never in source control. On the server side, store only a hash so a database leak does not expose working keys.
Browse other tools
All tools run entirely in your browser — nothing you type is sent to a server, except the optional HIBP 5-character hash prefix.