API Key Generator
Your secret
Generating in your browser…
Generated on your device with the Web Crypto API. Never sent or stored.
Prefer the terminal?
- OpenSSL
openssl rand -hex 32
How to use your API key
Copy the value above and add it to your key store, and show it to the user once. Keep it out of source control: commit an .env.example with an empty value instead, and set the real value in your hosting provider's environment settings or a secrets manager.
A good API key is long, random and easy to recognise. A short prefix such as sk_live_ or myapp_ makes leaked keys easy to spot in logs and lets secret scanners find them. On the server, store only a hash of each key (for example SHA-256), the same way you would store a password, and compare hashes on each request.
Is it safe to generate secrets in a browser?
Only if the secret is created locally, which is how this page works. The value comes from crypto.getRandomValues, the same cryptographically secure source browsers use for TLS keys, and it never leaves your device: there is no network request, log or analytics event that includes it.
If you prefer the command line, the commands on this page produce an equivalent secret on your own machine. Either way, use a different secret for development, staging and production, and rotate it straight away if it ever appears in a log, a screenshot or a public repository.
Frequently asked questions
How should I store API keys on my server?
Store only a hash (for example SHA-256) of each key, like a password, and show the full key to the user once.
How long should an API key be?
At least 128 bits of randomness; 256 bits (32 bytes) is a common default and what this page uses.