Secret key generator
Runs in your browserGenerate cryptographically random secrets: JWT HS256 keys, webhook secrets, AES keys, Laravel APP_KEY, Django SECRET_KEY, API keys. In hex, Base64 or Base64url.
- .env line
From your browser’s random number generator
The bytes come from crypto.getRandomValues(), the same cryptographically secure generator your browser uses for TLS keys. Nothing is generated on a server and nothing is stored. Letters-and-digits and Django formats pick characters without bias (no modulo).
The same without a browser
openssl rand -hex 32 # 64 hex characters openssl rand -base64 32 # 44 characters Base64
node -e "console.log(require('crypto').randomBytes(32).toString('base64url'))"python3 -c "import secrets; print(secrets.token_urlsafe(32))"
php artisan key:generate --show python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
Keep secrets secret
Put secrets in environment variables or a secret manager. If one was committed, rotate it; removing the commit is not enough.
128 bit (16 bytes) resist guessing; 256 bit (32 bytes) are the norm for HMAC and JWT secrets.
Use separate secrets for each environment and service, so one leak doesn’t open everything.
Questions about the secret key generator
Are these keys really random?
Yes. They come from the Web Crypto API, which is backed by the operating system’s secure random generator. Math.random is not used.
How long should a JWT secret be?
At least 32 bytes (256 bit) for HS256, 64 bytes for HS512. Shorter secrets can be brute-forced offline from a single token.
Is a Base64 secret weaker than hex?
No, the format only changes how the same bytes are written. 32 bytes are 256 bit in hex (64 characters) and in Base64 (44 characters).