Sign and verify JSON Web Tokens with HS256, HS384, or HS512. Uses the browser's Web Crypto API, your secret never leaves the page.
Algorithm:
Payload (JSON)
Ctrl+EnterRunCtrl+KClearHS256/384/512 via Web Crypto API. Nothing leaves your browser.
Share this tool
Found it useful? Help a fellow developer discover it.
https://developertoolkit.dev/tools/jwt-generator
JWT structure
A JWT consists of three base64url-encoded parts separated by dots:
HEADER
Declares the token type (JWT) and signing algorithm (e.g. HS256). Base64url-encoded JSON.
PAYLOAD
Claims about the subject, user ID, name, expiry (exp), issued-at (iat), etc. Base64url-encoded JSON.
SIGNATURE
HMAC of header + "." + payload using your secret. Proves the token was not tampered with.
HS256 vs HS384 vs HS512
Algorithm
Hash
Signature size
Min. secret length
Recommendation
HS256
SHA-256
43 chars
32 bytes recommended
Most common, sufficient for most use cases
HS384
SHA-384
64 chars
48 bytes recommended
Higher security margin, rare in practice
HS512
SHA-512
86 chars
64 bytes recommended
Highest security, larger tokens, fast on 64-bit
When to use JWTs
Stateless API authentication. After a user logs in, the server issues a JWT. The client sends it with every request in the Authorization header. The server verifies the signature without a database lookup, making authentication fast and horizontally scalable.
Microservice to microservice trust. Service A signs a JWT with its private key and Service B verifies it using the public key. No shared session store needed between services.
Short-lived access tokens. Set exp to 15 minutes for access tokens and issue a long-lived refresh token separately. Exchange it for a new access token when the short one expires. This limits the exposure window if an access token is stolen.
One-time action links. Embed a user ID and action in a JWT with a short expiry and send it in an email link for password reset or email verification. The server validates the token without storing any extra state.
Testing and debugging. Use this tool to generate signed tokens for staging environments, verify tokens from production logs, or simulate expired and invalid tokens during integration testing.
Frequently Asked Questions
Is it safe to generate JWTs in the browser?
For testing and development, yes. This tool uses the browser's native Web Crypto API, your secret is never sent over the network. For production systems, generate tokens server-side where the secret is protected by environment variables and never exposed to clients. Browser-generated tokens should only be used for testing.
What is the difference between HS256 and RS256?
HS256 uses a symmetric secret (same key to sign and verify). RS256 uses an asymmetric RSA key pair, the private key signs the token, and the public key verifies it. RS256 is better when multiple services need to verify tokens without sharing a secret. This tool supports HS* algorithms only.
What claims should every JWT have?
At minimum: iss (issuer), sub (subject/user ID), iat (issued-at timestamp), and exp (expiry timestamp). The exp claim is critical, without it, a stolen token is valid forever. A typical expiry is 15 minutes for access tokens and 7–30 days for refresh tokens.
Why is my JWT verification failing?
Common causes: wrong secret (it must be identical to the one used to sign), algorithm mismatch (the verifier must use the same algorithm as the signer), the token is expired, or the token was URL-decoded (plus instead of dash, slash instead of underscore). Paste the raw token directly without decoding it first.
How do I generate a JWT for testing?
Enter a JSON payload in the payload panel. A minimal test payload is: {"sub": "user123", "iat": 1700000000, "exp": 1700003600}. Enter any string as your secret, select HS256, and the signed token appears instantly. Copy it to use in Authorization headers or paste it into the JWT Decoder to inspect the claims.
How do I set the exp claim correctly?
exp is a Unix timestamp (seconds since 1 January 1970 UTC). To set a 1-hour expiry, take the current Unix timestamp and add 3600. For a 15-minute expiry add 900. Use the Timestamp Converter tool to get the current Unix timestamp, then add the desired seconds and paste the result into your payload.
How long should a JWT access token be valid?
15 minutes is the standard recommendation for access tokens in production. Short expiry limits the exposure window if a token is stolen. Pair them with a longer-lived refresh token (7 to 30 days) stored in an HttpOnly cookie, exchanged silently for new access tokens without requiring the user to log in again.
Can I use JWT for session management?
Yes, but with trade-offs. JWTs are stateless so you cannot invalidate an individual token before it expires without maintaining a server-side blocklist, which negates the stateless benefit. For applications that need immediate logout or revocation, traditional server-side sessions with a session store are simpler. JWTs are best for stateless APIs, microservices, and short-lived credentials.