JWT Generator
Sign a JWT online in seconds: edit the header and payload, add exp and iat with one click, and sign with an HS256 secret or an RS256, PS256 or ES256 private key. You can also generate a test key pair as PEM. Signing runs locally in your browser with the Web Crypto API. To read an existing token, use the JWT Decoder.
Signing…
Want to inspect a token you received? Paste it into the JWT Decoder to read its header, payload and expiry.
How to create a JWT
- Choose an algorithm. Pick HS256, HS384 or HS512 to sign with a shared secret, or RS256, PS256, ES256 and their variants to sign with a private key.
- Edit the header and payload. Edit the JSON directly, or use the quick buttons to add iat, nbf and exp (+1 hour, +1 day or a custom time) and the sub, iss, aud and jti claims.
- Add the secret or key. Type a secret as text or Base64 for HMAC. For RSA or ECDSA, paste a PKCS#8 PEM private key or click Generate key pair to create one along with its public key.
- Copy the token. The signed token updates as you type, colour-coded into header, payload and signature. Click Copy token, and share the public key with whoever verifies it.
Anatomy of a signed JWT
A JWT is three Base64URL strings joined by dots: header.payload.signature. The header names the algorithm (alg) and type; the payload holds the claims; the signature is computed over base64url(header) + "." + base64url(payload). The payload is only encoded, not encrypted, so anyone holding the token can read it. Don't put passwords or personal data in it.
The registered claims you will use most often:
sub— subject, usually the user IDiss/aud— who issued the token and who it is foriat/nbf/exp— issued-at, not-before and expiry, as Unix secondsjti— a unique token ID, useful for revocation lists
Signing keys: secret vs key pair
With HMAC (HS256/384/512) the same secret signs and verifies, which suits a single service that issues and checks its own tokens. With RSA (RS*, PS*) or ECDSA (ES*), the issuer keeps the private key and publishes the public key, often as a JWKS endpoint, so other services can verify tokens without being able to forge them. ES256 keys and signatures are much smaller than RSA's for similar security; PS256 is the more modern RSA padding.
Keys from Generate key pair are created with crypto.subtle.generateKey and exported as PKCS#8 (private) and SPKI (public) PEM, the formats most JWT libraries accept. They exist only in this tab and are gone when you close it.
Related tools
Frequently Asked Questions
How do I create a JWT online?↓
Choose an algorithm such as HS256, edit the payload JSON with your claims, enter a secret, and the signed token appears instantly. Click Copy token. For RS256 or ES256, click Generate key pair or paste your own PKCS#8 private key instead of a secret.
Is it safe to sign a JWT in the browser?↓
This tool signs tokens locally with the Web Crypto API and never sends your secret, key or token anywhere, and keys are not saved. Even so, never paste production secrets or private keys into any website. Use test keys here and keep real signing keys on your server or in a key management service.
What is the difference between HS256, RS256 and ES256?↓
HS256 uses one shared secret to both sign and verify, so every verifier can also create tokens. RS256 signs with an RSA private key and verifies with the public key, so verifiers can't forge tokens. ES256 works like RS256 but uses an elliptic-curve P-256 key, giving much shorter keys and signatures.
How long should an HS256 secret be?↓
RFC 7518 requires an HMAC key at least as long as the hash output: 32 bytes (256 bits) for HS256, 48 bytes for HS384 and 64 bytes for HS512. The tool warns when a secret is shorter, and the Random secret button (for example Random 256-bit secret) creates one of the right length.
How do I set an expiry (exp) on a JWT?↓
Click exp: +1 hour, exp: +1 day or exp: +7 days, or enter a number of minutes, hours or days and click Set exp. The exp claim is stored as a Unix timestamp in seconds, and the Time claims panel shows it as a date with the time remaining.
Why is my RSA or EC private key rejected?↓
The Web Crypto API needs an unencrypted PKCS#8 key beginning with -----BEGIN PRIVATE KEY-----. Keys starting with BEGIN RSA PRIVATE KEY or BEGIN EC PRIVATE KEY can be converted with: openssl pkcs8 -topk8 -nocrypt -in key.pem -out key-pkcs8.pem. Also check that the key type matches the algorithm, for example a P-256 key for ES256.
Last updated: