About the Secret Key Generator tool
Frameworks and libraries need random secrets to sign cookies, tokens and sessions: Django's SECRET_KEY, Laravel's APP_KEY, Rails' secret_key_base, the key behind HS256 JWTs, an Auth.js AUTH_SECRET. Using a weak or reused value, or a placeholder from a tutorial, lets attackers forge sessions and tokens. Generating a proper one usually means remembering the right command for each framework.
This generator produces secrets with crypto.getRandomValues, the browser's cryptographically secure random generator, in the shape each framework expects. Choose a preset and you get the right length and encoding, plus a ready-to-paste config line: a 50-character Django key with Django's own alphabet, a base64: prefixed 32-byte Laravel key, a 128-hex-character Rails key, a 32 or 64-byte Base64URL JWT secret and more. The Custom preset lets you pick any length from 8 to 128 bytes in hex, uppercase hex, Base64 or Base64URL.
The entropy is shown in bits so you know how strong the value is. Secrets are generated locally and not stored or sent; still, keep real secrets in environment variables or a secrets manager rather than in source control.
How to use Secret Key Generator
- Select a preset under “Framework / use”, such as JWT HS256 secret or Django SECRET_KEY.
- Adjust the “Length” slider and “Encoding” if you need something different.
- Copy the secret, or copy the “Config line” ready for your .env or settings file.
- Click “Regenerate” for a new value.
Features
Framework presets
JWT HS256/HS512, Django, Laravel, Rails, Flask/FastAPI, Auth.js and session cookie secrets.
Correct shapes
Matches the alphabet, length and prefix produced by each framework's own generator command.
Four encodings
Hex, uppercase hex, Base64 and URL-safe Base64 without padding.
Config line
Each preset includes a ready-to-paste line such as APP_KEY=base64:… or SECRET_KEY = '…'.
Entropy display
Shows bits of randomness and a simple strength rating.
When to use it
- Create a production SECRET_KEY before deploying a Django project.
- Set APP_KEY for a Laravel app on a server where you cannot run artisan.
- Generate a JWT signing secret for a Node.js or Go API.
- Rotate a session secret after a leak.
- Create a random API key or webhook signing secret.
Frequently asked questions
How long should a JWT secret be?
At least as long as the hash output: 32 bytes (256 bits) for HS256 and 64 bytes for HS512, as required by RFC 7518.
Is a browser-generated secret secure?
Yes. crypto.getRandomValues draws from the operating system's secure random generator, the same source used by command-line tools.
Can I change the length of a Laravel APP_KEY?
No. Laravel's default AES-256-CBC cipher needs exactly 32 bytes, so the Laravel preset is fixed at that size.
What happens if I change the secret of a running app?
Existing sessions, remember-me cookies and signed tokens become invalid, and for Laravel any data encrypted with the old key can no longer be decrypted. Plan rotations accordingly.
Is the secret saved anywhere?
No. It exists only on this page until you leave or regenerate it.