Secret Key Generator

Make a strong random secret for an app: the key that signs JWTs, the shared secret for webhook HMAC signatures, a session or cookie secret, or an API token. The default is 256 bits (32 bytes) as Base64URL, with the line to paste into your .env file. The key is made in your browser and is never sent to us or stored, so copy it before you leave the page.

What to make
Format
Randomness
256 bits
Length
43 chars
Bytes
32
Generated
0

Generating runs in your browser. What you type never leaves this device.

Features

  • 256-bit keys by default; 128 to 512 bits available

  • Hex, Base64 or URL-safe Base64URL

  • A ready KEY=value line for .env files, with the variable name you choose

  • Make up to 500 keys at once, for example one per environment or customer

  • Warns when a key is shorter than 128 bits

  • Secure randomness from crypto.getRandomValues

  • Runs in your browser: the key is never sent, logged or saved

Where you need a secret key

JWT signing (HS256)

An HS256 secret should be at least 256 bits. Paste it into JWT_SECRET, then try it in the [JWT generator](/tools/jwt-generator).

Webhook signatures

The shared secret you give a payment gateway or CRM to sign webhooks with HMAC-SHA256; check signatures with the [webhook signature verifier](/tools/webhook-signature-verifier).

Session and cookie secrets

SESSION_SECRET, NEXTAUTH_SECRET, Flask SECRET_KEY and similar settings that sign cookies.

API tokens

A long random token to give an internal service or a partner, stored hashed on your side.

Using a secret key safely

Size and format

  • 256 bits (32 bytes) is the usual size for HMAC-SHA256 and HS256 JWT secrets. Longer adds nothing for those algorithms.
  • Use the format your framework reads. Most accept any string; some expect Base64 or hex and decode it to bytes, so check the docs if a key length error appears.

Keeping it secret

  • Put the key in an environment variable or a secrets manager, not in source code or a Git repository.
  • Use a different key for development, staging and production.
  • If a key leaks, make a new one and replace it everywhere; old tokens signed with it stop working.

Not for passwords people type

These keys are for machines. For a password a person will type, use the password generator.

Secret Key Generator - FAQ