Base64 Encode & Decode · Tutorial
How to decode a JWT and read its payload
6 min readbeginnerUpdated
When a login or API call fails, the answer is often inside the token itself. Maybe it has expired, or it lacks a role. A JWT is just three Base64-encoded parts joined by dots. This tutorial shows how to decode one safely, read the claims that matter, and convert its timestamps into real dates.
What you need
- The Base64 Encode & Decode
- A JWT, for example from your browser's developer tools, an
Authorization: Bearerheader, or the sample behind Try it
Steps
Copy the token
A JWT looks like
xxxxx.yyyyy.zzzzz: three groups of letters, digits,-and_, separated by dots. If you copied a header such asAuthorization: Bearer eyJ..., keep only the part afterBearer.Paste it into the decoder
Paste the whole token into the left box. The tool recognises the three-part shape, decodes the first two parts as URL-safe Base64, and formats each as JSON. A green note confirms it was read as a JWT.
Read the header
The header describes how the token was signed.
algis the signing algorithm (for exampleHS256orRS256) andtypis usuallyJWT. You rarely need to change anything here, but an unexpected algorithm can explain why a server rejects a token.Read the payload claims
The payload holds the claims: facts the issuer vouches for. Common ones are
sub(the user or subject ID),exp(expiry time),iat(issued at), and app-specific claims likeroleorscope. In the sample, the useruser_8841has the roleeditor.{ "sub": "user_8841", "name": "Sam Rivera", "role": "editor", "iat": 1793260800, "exp": 1793264400 }Convert the timestamps
iatandexpare Unix timestamps: seconds since 1 January 1970 UTC. In the sample,expis exactly 3,600 seconds afteriat, so the token was valid for one hour. Ifexpis in the past, the token has expired and the user must log in again or refresh it. A quick check in your browser console isnew Date(1793264400 * 1000).
Try it yourself
Opens the Base64 Encode & Decode with this tutorial's sample loaded.
Common mistakes
- Including the Bearer prefix or quotes
- Extra text such as
Beareror surrounding quotation marks stops the tool from recognising the token. Paste only the three dot-separated parts. - Assuming a decoded token is valid
- Anyone can create a token with any payload. Decoding shows what it says, not whether it is genuine. Only signature verification on the server proves that.
- Pasting production tokens into online tools that upload them
- A live token can be used to act as that user until it expires. This decoder runs in your browser, but be careful with any site that sends input to a server.
Next steps
Go back to the Base64 Encode & Decode, or keep going with one of these:
FAQ
Why can't I decode the third part?
The third part is the signature, which is raw binary produced by the signing algorithm. It is not meant to be read, only verified with the right key.
Can I edit the payload and use the token?
Changing the payload breaks the signature, so a correctly configured server will reject the edited token.