Three parts joined by dots
A JSON Web Token is written as header.payload.signature. The header states the algorithm, the payload holds the claims, and each is converted to Base64URL, a version of Base64 that uses - and _ and drops the = padding so the token is safe in a URL. The signature is computed like this:
HMAC-SHA256(
base64url(header) + "." + base64url(payload),
secret
)
Signing happens in your browser with the Web Crypto API. The secret is not sent to our server or saved between visits. The resulting token can be checked with any standard JWT library or with the JWT Verifier on this site.
Registered claims worth knowing
RFC 7519 reserves a handful of short names. All are optional, and your application decides which it requires:
- iss names who issued the token, and aud names who it is intended for.
- sub identifies the subject, usually a user ID.
- exp is the expiry time, nbf is the time it becomes valid, and iat records when it was issued.
- jti gives the token a unique ID, which helps when you need to block one.
The three time claims are in seconds since 1970. JavaScript’s Date.now() returns milliseconds, and using it directly sets an expiry tens of thousands of years away, a mistake that is easy to miss because the token keeps working. The Expiration menu here writes seconds for you.
Signed does not mean secret
Anyone holding a token can decode its payload without the key. The signature only proves the content has not been changed since it was signed. Keep passwords, card numbers and personal details out of the claims. If the contents must be hidden, the separate JWE standard covers encrypted tokens.
How long the secret should be
RFC 7518 requires an HMAC key at least as long as the hash output: 256 bits for HS256, 384 for HS384 and 512 for HS512. A short memorable phrase can be guessed offline, because an attacker with one token can try millions of secrets against it without contacting your server. The Generate Secret button produces 256 random bits, which suits HS256. Use a longer key for the other two.
Shared secrets and their limits
The HS algorithms use one key for both signing and verifying, so any service that can check a token can also create one. When several independent services need to verify tokens, asymmetric algorithms such as RS256 or ES256 are a better fit, since only the issuer holds the private key. This encoder covers the HMAC family only.
Use tokens made here for testing, and never paste a production secret into a web page, even one that works locally like this.