Random Secret Generator
Create 128 to 512 bit secrets for config and signing.
Options
Result
Nothing to build with these settings.
A random secret generator for config and signing keys
Generate 128 to 512 bit secrets in hex, Base64 or Base64url, ready for a .env file, a JWT signing key or an encryption key.
- Sized in bits. Pick 128, 192, 256, 384 or 512 bits, and see the byte count.
- Three encodings. Hex, standard Base64 or URL-safe Base64url, made from raw random bytes.
- Ready for .env. Type a variable name such as SESSION_SECRET and the result comes out as SESSION_SECRET=value.
- Private. Made in your browser from the secure random source and never sent anywhere.
Uses of a random secret generator
Most frameworks ask for a long random string. This makes one at the right size.
- Session and cookie secrets. Create the value for SESSION_SECRET or an auth library’s secret setting.
- JWT and HMAC signing keys. A 256-bit secret is the usual size for HS256.
- Encryption keys. Use 128 or 256 bits for AES keys, encoded the way your code expects.
- Webhook secrets. Share a random value between your service and a provider.
Random secret generator questions
What size should I choose?
256 bits suits almost every case, including HS256 signing and AES-256. Use 128 bits only where a library asks for it.
Hex, Base64 or Base64url?
They carry the same entropy. Hex is the longest, Base64 the shortest, and Base64url avoids characters that need escaping in URLs.
Where should I keep the secret?
In your host’s environment variables or a secret manager. Never commit it to a repository or put it in client-side code.
Can I rotate it later?
Yes, and you should plan to. Generate a new one, deploy it, and keep the old one valid briefly if your system supports key rollover.