How to Decode a JWT and Read Its Claims
Security · Published October 9, 2026 · Updated October 24, 2026 · 3 min read
Written by Akinrinmade Michael · General information, not professional advice
A JSON Web Token, or JWT, is a compact string that apps use to prove who you are. It often looks like three blocks of random letters joined by dots. Inside, it's just JSON that has been encoded, and reading it takes a minute once you know the layout.
The three parts
xxxxx.yyyyy.zzzzz header.payload.signature
- Header: the token type and the signing algorithm, such as HS256 or RS256.
- Payload: the claims, which are facts about the user and the token.
- Signature: proof that the header and payload haven't been changed.
The header and payload are encoded with Base64URL, a web-safe version of Base64. Anyone can decode them. That's why you should never put secrets such as passwords in a JWT. The Base64 Encoder can decode a part by hand if you're curious.
A token taken apart
Here's a well-known sample token, with each piece decoded:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
-> {"alg":"HS256","typ":"JWT"}
eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ
-> {"sub":"1234567890","name":"John Doe","iat":1516239022}
SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
-> the signature (binary, only meaningful with the secret)Claims you will see often
| Claim | Meaning | What to check |
|---|---|---|
sub | The subject, usually a user ID | It's the account you expect |
iss | The issuer, the service that created the token | It matches your identity provider |
aud | The audience the token is meant for | It names your app or API |
iat | When it was issued | A sensible time in the past |
exp | When it expires | It's in the future |
nbf | The time before which it must not be accepted | It's in the past |
The time claims are Unix timestamps, counted in seconds. Paste them into the Unix Timestamp Converter to see a readable date. The sample above was issued on 18 January 2018.
Decoding isn't verifying
Reading a token only tells you what it says. To trust it, your server must check the signature with the right key, confirm the expiry time and check the issuer and audience. A decoder on a website can't do that without your secret, so never treat a decoded token as proof of anything.
What a server should check, in order
- The token has three parts and decodes cleanly.
- The algorithm is one you allow. Never accept
none, and don't let the token choose its own algorithm. - The signature is valid for the right key.
- The
exptime hasn't passed, allowing a small margin for clock differences. - The
issandaudmatch what you expect. - The
nbftime, if present, has been reached.
HS256 or RS256
HS256 uses one shared secret both to sign and to verify, so every service that checks tokens must hold the secret. RS256 uses a private key to sign and a public key to verify, so many services can check tokens without being able to make them. Larger systems usually prefer RS256 for that reason. A decoder can verify HS256 if you give it the secret, and can only read RS256 tokens.
Why a token fails
- Expired. Compare exp with the current time. Clocks that disagree by a minute can reject a fresh token.
- Wrong audience or issuer. The token was made for another app or a staging server.
- Bad signature. The secret differs, the token was altered, or it was signed with another algorithm.
- Stray characters. A trailing space, a line break or a leading
Bearercan break parsing.
Keeping tokens safe
- Give access tokens a short life, such as 15 minutes, and use a separate refresh token for longer sessions.
- Store them where scripts on the page can't read them if you can, such as in an HTTP-only cookie.
- Send them only over https.
- Don't put personal data in the payload, since anyone can read it.
Debugging with the decoder
Paste your token into the JWT Decoder to see the header, the claims and whether it has expired. It runs in your browser, so the token isn't sent anywhere. Even so, avoid pasting live production tokens into any tool you don't control, and prefer an expired or test token when you can.
Related reading: the time claims in a token are Unix timestamps, covered in Unix timestamps explained.