Secret Key Generator
Generate a strong random secret for your app's configuration — JWT, sessions, API keys — in the format you need.
● 🔒 Your data is processed locally in your browser with the Web Crypto API and is never uploaded to our servers.
How to generate a secret key
- Choose the type: prefixed key (
sk_live_…), hex secret, Base64URL secret, alphanumeric, UUID v4, JWT HS256 secret, salt or AES-GCM IV. - Set the strength in random bytes — 32 bytes (256 bits) is a safe default — and, for prefixed keys, the prefix.
- Choose how many keys you need and click Generate, then copy.
Which format for which framework?
| Where | Setting | Good choice |
|---|---|---|
| Django | SECRET_KEY | Alphanumeric or Base64URL, 50+ characters |
| Rails | secret_key_base | Hex, 64 bytes (128 characters) |
| Laravel | APP_KEY | base64: + 32 random bytes in Base64 |
| Express / Flask sessions | SESSION_SECRET, SECRET_KEY | Hex or Base64URL, 32 bytes |
| JWT signed with HS256 | Signing secret | JWT HS256 secret (256-bit) |
| Your own API | API keys for clients | Prefixed key, like sk_live_… |
Frameworks also have their own commands: bin/rails secret, php artisan key:generate, or openssl rand -base64 32 anywhere.
Why prefixed keys?
A prefix like sk_live_ or pk_test_ tells at a glance what a key is for and which environment it belongs to. It also lets secret-scanning tools detect leaked keys in code repositories. Keep the random part long — the prefix adds no security by itself.
How to keep secrets safe
- Never commit secrets to Git. Store them in environment variables, a
.envfile listed in.gitignore, or a secrets manager. - Use a different secret per environment (development, staging, production).
- Rotate a secret if it leaks — and remember that changing a session or JWT secret logs everyone out.
- Don't reuse a secret across apps or for different purposes.
FAQ
How long should a secret key be?
At least 32 random bytes (256 bits). Longer doesn't hurt, but anything over 128 bits is already impossible to brute-force.
Is it safe to generate keys in a browser?
Yes, with the Web Crypto API: keys are created on your device from a cryptographically secure source and never uploaded. For production secrets, many teams still prefer generating them on the server.
Where are other key tools?
See the API Key Generator, the Random Bytes Generator and the RSA Key Pair Generator.