Skip to content

JWT Secret Generator

Generate cryptographically secure secret keys for signing JWTs.

Runs in your browser.Input is not sent to our API.
Generated JWT Secret256 bits(32 bytes)
guXvirwOTnKA2T1nR4sBCfTjpkpTlkORD21LH_mZTSQ

Recommended for HS256. RFC 7518 specifies a key of 256 bits (32 bytes) or greater.

32 bytes (256 bits)
16 B (128 b)32 B (HS256)48 B (HS384)64 B (HS512)128 B (1024 b)
How to use this secret in code
# In your .env file:
JWT_SECRET="guXvirwOTnKA2T1nR4sBCfTjpkpTlkORD21LH_mZTSQ"

Generated locally in your browser with Web Crypto (crypto.getRandomValues). Secrets are never sent over the network, saved in storage, or transmitted to any server.

How to use this tool

  1. Select an algorithm preset (HS256 with 32 bytes, HS384 with 48 bytes, or HS512 with 64 bytes), or pick a custom key size using the slider.
  2. Choose your desired output encoding format: Base64URL (RFC 7515 standard for JWT), Base64, Hexadecimal, or printable UTF-8 text.
  3. Click Generate new secret at any time to create fresh cryptographic randomness, then click Copy to copy the secret or code snippet.

What the result means

JSON Web Tokens signed with HMAC algorithms (such as HS256, HS384, or HS512) rely on a symmetric shared secret to generate and verify signatures. According to RFC 7518 Section 3.2, the key size must be equal to or greater than the hash output size of the algorithm (256 bits for HS256, 384 bits for HS384, and 512 bits for HS512). Weak or short secrets leave tokens vulnerable to offline dictionary and brute-force attacks where attackers recover the secret and forge arbitrary tokens.

Example

An HS256 secret generated in Base64URL format will be a 43-character string containing 32 random bytes (256 bits of entropy), such as dGVzdC1zZWNyZXQta2V5LWZvci1qd3Qtc2lnbmluZw. In Hexadecimal format, that same 32-byte key is 64 characters long.

Limitations

This tool generates symmetric HMAC keys for HS256, HS384, and HS512. It does not generate asymmetric keypairs (such as RSA or ECDSA keys used for RS256 or ES256). Secrets are generated entirely in your browser using the Web Crypto API and are never saved or sent to any server. Once you leave this page, the displayed secret cannot be recovered unless you copied it.

Common questions

Is this secret safe to use in production?

Yes. The secret is produced directly in your browser using window.crypto.getRandomValues(), the modern standard for cryptographically secure pseudo-random number generation (CSPRNG). No secrets are sent across the network or stored on any server.

Which algorithm should I choose: HS256, HS384, or HS512?

HS256 (HMAC-SHA256 with a 256-bit / 32-byte key) is the universal industry standard and is supported by virtually all authentication libraries. HS384 and HS512 provide larger keys and hash outputs for applications with elevated security requirements.

Why is Base64URL recommended for JWTs?

Base64URL encoding (RFC 7515) avoids '+' and '/' characters and omits '=' padding, making the string safe to pass in HTTP headers, cookies, and query parameters without URL encoding.