How to use the JWT decoder
- Paste the token. A
Bearerprefix copied from a header is removed automatically. - Read the coloured token: header, payload and signature are shown in different colours.
- Check the decoded header and payload, then the claims table with dates in UTC and relative times.
- Review the checks for expiry, algorithm and risky claims.
- Optionally verify an HMAC signature by entering the shared secret. The sample token’s secret is
demo-secret-change-me.
How a JWT is built
A JWT is three Base64URL-encoded parts joined by dots: header.payload.signature.
- The header names the algorithm (
alg, for example HS256 or RS256) and usually the type (typ: JWT) and key ID (kid). - The payload holds claims. Registered claims include
iss(issuer),sub(subject),aud(audience),exp(expiry),nbf(not before),iat(issued at) andjti(token ID). Times are seconds since 1 January 1970 UTC. - The signature is computed over the first two parts. With HS256 it’s an HMAC-SHA256 using a shared secret; with RS256 it’s an RSA signature that anyone can check with the public key.
Decoding needs no key. Verifying does.
Worked examples
Example 1: the sample token
The sample decodes to a user with read and write scopes, issued by auth.example.com for example-api. The checks show it’s signed with HS256 and not expired, but valid for over three years, which is far too long for an access token. Enter the secret and verification succeeds; change one character of the secret and it fails.
Example 2: debugging a 401 error
Paste the token your app is sending. If the check says Expired 2 h ago, the client isn’t refreshing tokens. If aud doesn’t match your API’s identifier, the server rejects it even though the signature is valid.
Example 3: an unsigned token
A token with "alg": "none" and an empty signature is flagged in red. Servers must never accept these, because anyone can create them. Allow-list the algorithms your server accepts.
Good practice for JWTs
- Keep access tokens short-lived (minutes to an hour) and use refresh tokens.
- Always validate
exp,nbf,issandaudon the server, with a few seconds of clock skew. - Don’t store sensitive data in the payload; it’s readable.
- Store browser tokens in HttpOnly cookies where possible, to limit theft by scripts.
Common mistakes
- Trusting a decoded token without verifying it. Anyone can edit the payload and re-encode it.
- Using a weak HMAC secret. Short secrets can be brute-forced offline; use at least 32 random bytes.
- Confusing JWS with JWE. A five-part token is encrypted and can’t be decoded without its key.
- Millisecond timestamps. JWT times are in seconds; a 13-digit
expis a bug.