Secret key generator

Runs in your browser

Generate 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
How it’s made

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).

In your terminal

The same without a browser

openssl
openssl rand -hex 32        # 64 hex characters
openssl rand -base64 32     # 44 characters Base64
Node.js
node -e "console.log(require('crypto').randomBytes(32).toString('base64url'))"
Python
python3 -c "import secrets; print(secrets.token_urlsafe(32))"
Laravel / Django
php artisan key:generate --show
python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
Good practice

Keep secrets secret

Not in git

Put secrets in environment variables or a secret manager. If one was committed, rotate it; removing the commit is not enough.

Long enough

128 bit (16 bytes) resist guessing; 256 bit (32 bytes) are the norm for HMAC and JWT secrets.

One per purpose

Use separate secrets for each environment and service, so one leak doesn’t open everything.

FAQ

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).

Searches the list of pages on this site. What you type stays in your browser.