Home › Developer Tools › JWT Generator

JWT Generator

Build a JSON Web Token from a header and payload, sign it with an HMAC secret and copy it. Signing uses the browser's Web Crypto API, so your secret never leaves this page.

Encoded token
HeaderPayloadSignature
Signing input –

Verify a token

Paste a token to check it
Advertisement
Advertisement

How to use the JWT Generator

  1. Choose the algorithm: HS256, HS384 or HS512. The header's alg field updates automatically.
  2. Edit the payload claims as JSON and use the buttons to set iat, nbf, exp or a random jti.
  3. Enter the secret your server uses, or press Random secret. Tick the Base64 box if the secret is stored encoded.
  4. Press Generate JWT (the token also updates as you type) and copy the token or the Bearer header.
  5. Verify a token: paste any HMAC-signed JWT and its secret below and press Verify Token.

How an HMAC-signed JWT is built

A JWS compact token is base64url(header) . base64url(payload) . base64url(signature). Base64url is Base64 with - instead of +, _ instead of / and no = padding. The signature is:

signature = HMAC-SHA256( secret, base64url(header) + "." + base64url(payload) )

Worked example (the well-known jwt.io token): header {"alg":"HS256","typ":"JWT"} becomes eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9; payload {"sub":"1234567890","name":"John Doe","iat":1516239022} becomes eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ. Signed with the secret your-256-bit-secret, the signature is SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c. Paste those values into the tool and you get exactly the same token.

Registered claims (RFC 7519)

ClaimNameMeaningExample
issIssuerWho created and signed the token"https://auth.example.com"
subSubjectThe user or entity the token is about"user_42"
audAudienceWho the token is meant for (string or array)"api.example.com"
expExpiration timeReject the token at or after this time (seconds)1767225600
nbfNot beforeReject the token before this time1767222000
iatIssued atWhen the token was created1767222000
jtiJWT IDUnique ID, used to prevent replay"n3Kp…"

HS256 vs HS384 vs HS512

AlgorithmHashSignature sizeSignature length (base64url)Minimum secret
HS256SHA-25632 bytes43 characters32 bytes (256 bits)
HS384SHA-38448 bytes64 characters48 bytes (384 bits)
HS512SHA-51264 bytes86 characters64 bytes (512 bits)

All three are symmetric: the same secret signs and verifies, so every service that checks the token can also create one. When many independent services must only verify tokens, an asymmetric algorithm such as RS256 or ES256 is the better choice.

Security tips for HMAC tokens

  • Generate the secret with a cryptographic random generator (the Random secret button uses crypto.getRandomValues) and keep it out of source control.
  • Always check exp on the server and keep access tokens short-lived (5–60 minutes).
  • Pin the expected algorithm when verifying, and never accept "alg": "none".
  • Remember that the payload is readable by anyone: store an ID, not personal data.

Frequently asked questions

What is a JWT?

A JSON Web Token (RFC 7519) is a compact, URL-safe string with three Base64url parts separated by dots: a header that names the algorithm, a payload of claims such as sub, iat and exp, and a signature that proves the first two parts were not changed.

How is an HS256 signature calculated?

The tool Base64url-encodes the compact JSON header and payload, joins them with a dot and computes HMAC-SHA256 of that text with your secret. The 32-byte result is Base64url-encoded without padding and appended as the third part. HS384 and HS512 use SHA-384 and SHA-512.

How long should my secret be?

RFC 7518 requires an HMAC key at least as long as the hash output: 32 bytes for HS256, 48 for HS384 and 64 for HS512. Short passwords can be brute-forced offline from any token, so use the Random secret button for real systems.

Are iat, nbf and exp in seconds or milliseconds?

Seconds. JWT time claims are NumericDate values: whole seconds since 1 January 1970 UTC. A value with 13 digits is probably in milliseconds and will be read as a date tens of thousands of years in the future.

Is the payload encrypted?

No. A signed JWT is only encoded, so anyone holding the token can read the claims. Never put passwords or other secrets in the payload. Use JWE if the content must be hidden.

Why does verification fail?

The usual causes are a different secret, a secret that is Base64-encoded on the server but entered as plain text here (or the reverse), a token that was changed after signing, or an algorithm other than HS256, HS384 or HS512.

Is my secret sent anywhere?

No. Tokens are signed and verified in your browser with the Web Crypto API. Nothing you type is uploaded or stored.

Related tools