Generate a secure JWT secret in one click
Cryptographically random secrets for HS256, HS384, and HS512 signing. Never sent to a server. Built for production authentication systems. Need to inspect a token instead? Try the JWT decoder or JWT validator.
Most popular generators
Browse all variants →Pre-configured, shareable pages for the format and length combinations developers reach for most.
Why your JWT secret matters
A JWT (JSON Web Token) secret is the symmetric signing key used by HMAC algorithms like HS256, HS384, and HS512 to sign and verify tokens. If an attacker obtains it, they can forge tokens for any user — see our full guide to what a JWT is.
Recommended length: at least 256 bits (32 random bytes) for HS256, 384 for HS384, 512 for HS512. Always generate from a CSPRNG — never use a passphrase. You can confirm the signature is valid with the JWT validator.
Supported algorithms
Minimum key sizes for the most common JWT signing algorithms. HMAC algorithms use the same secret to sign and verify; RS256 and ES256 are asymmetric and use a key pair. Not sure which to pick? Read HS256 vs RS256.
| Algorithm | Type | Minimum key size | Typical use |
|---|---|---|---|
| HS256 | Symmetric (HMAC-SHA256) | 256 bits (32 bytes) | Single-service auth, monoliths, simple APIs |
| HS384 | Symmetric (HMAC-SHA384) | 384 bits (48 bytes) | Higher-assurance HMAC signing |
| HS512 | Symmetric (HMAC-SHA512) | 512 bits (64 bytes) | Maximum-strength HMAC, long-lived tokens |
| RS256 | Asymmetric (RSA + SHA-256) | 2048-bit RSA key pair | Microservices, third-party token verification |
| ES256 | Asymmetric (ECDSA + SHA-256) | 256-bit EC key (P-256) | Mobile & IoT — smaller signatures, faster verify |
Features
How it works
Use cases by stack
Node.js & Next.js
Set JWT_SECRET or NEXTAUTH_SECRET in your environment and sign tokens with jsonwebtoken or jose.
Django & DRF
Use as SIMPLE_JWT["SIGNING_KEY"] for djangorestframework-simplejwt, or rotate SECRET_KEY carefully.
Spring Boot
Base64-decode the secret into a SecretKey for io.jsonwebtoken (jjwt) HMAC signing.
Go
Decode a hex-format secret with hex.DecodeString and pass it to golang-jwt/jwt as the HMAC key.
Serverless (Lambda/Vercel)
Store the secret in AWS Secrets Manager or Vercel environment variables — never bundle it into your function code.
Code examples
Sign a JWT with the secret you just generated. Prefer to build the token in-browser first? Use the JWT encoder.
Node.js
const jwt = require("jsonwebtoken");
const token = jwt.sign({ sub: "user_123" }, process.env.JWT_SECRET, {
algorithm: "HS256",
expiresIn: "15m",
});Python
import jwt, os
token = jwt.encode(
{"sub": "user_123"},
os.environ["JWT_SECRET"],
algorithm="HS256",
)Go
secret, _ := hex.DecodeString(os.Getenv("JWT_SECRET"))
token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
"sub": "user_123",
})
signed, _ := token.SignedString(secret)Java
SecretKey key = Keys.hmacShaKeyFor(
Base64.getDecoder().decode(System.getenv("JWT_SECRET")));
String jws = Jwts.builder()
.subject("user_123")
.signWith(key, SignatureAlgorithm.HS256)
.compact();Frequently asked questions
Full FAQ →What is a JWT?
JSON Web Token is a compact, URL-safe token format (RFC 7519) used to transmit signed claims between parties. It consists of three Base64URL-encoded segments: header, payload, and signature.
What is a JWT secret?
The JWT secret is the symmetric key used by HMAC algorithms (HS256/HS384/HS512) to sign and verify tokens. Anyone holding it can issue valid tokens, so it must stay private.
What length should my JWT secret be?
At minimum match the algorithm's output size: 256 bits (32 bytes) for HS256, 384 bits for HS384, 512 bits for HS512. Longer is fine; shorter weakens signing security.
Is this generator safe to use?
Yes. Every secret is produced locally in your browser using the Web Crypto API (crypto.getRandomValues). Nothing is transmitted, logged, or stored on any server.
How often should I rotate JWT secrets?
Rotate on a schedule (every 90 days is common) and immediately if compromise is suspected. Use a JWKS endpoint or key-id (kid) header so tokens signed under old keys remain verifiable during the rollover.
JWT vs session cookies — which should I use?
Sessions are simpler and easier to revoke. JWTs scale well for stateless APIs and microservices. Many production systems use both: short-lived JWT access tokens plus server-side refresh sessions.
What is HS256?
HMAC-SHA256 — a symmetric JWT signing algorithm that uses a shared secret. Fast and simple, but the same key signs and verifies, so every verifier must be trusted.
What is RS256?
RSA Signature with SHA-256 — an asymmetric algorithm. The private key signs, the public key verifies. Preferred when verifiers should not be able to issue tokens.
Can a JWT be hacked?
JWTs themselves are tamper-evident, but implementations are routinely attacked: weak HS256 secrets brute-forced offline, the 'none' algorithm bypass, algorithm-confusion (RS256 → HS256), and leaked secrets in source control.
Can I use a passphrase as my JWT secret?
No. Passphrases have far less entropy than random bytes and are crackable offline. Always generate from a CSPRNG — that is exactly what this tool does.
What is a refresh token?
A long-lived token (often opaque, stored server-side) used to obtain new short-lived access tokens without requiring the user to re-authenticate.
Where should I store the JWT secret?
In a secrets manager (AWS Secrets Manager, GCP Secret Manager, HashiCorp Vault) or environment variables managed by your platform. Never commit it to git.
Latest from the blog
All posts →More JWT tools
Related tools
Recent articles
Guides on JWT secrets, signing algorithms, and token security.