How to Decode a JWT and Read Its Claims
A JSON Web Token (JWT) is the long string you see in Authorization: Bearer eyJhbGci... headers. It looks encrypted, but most JWTs are only encoded: anyone who has the token can read what is inside. This guide shows how to decode one, what each standard claim means, and the one mistake you should never make with decoded tokens.
The three parts of a JWT
A JWT is three Base64URL-encoded parts separated by dots:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 . eyJzdWIiOiIxMjM0NSIsImV4cCI6MTkwMDAwMDAwMH0 . SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
โโโโโโโโโโโโโโโ header โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ payload โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ signature โโโโโโโโโโโโโโโโโ- Header: which algorithm signed the token, for example
{ "alg": "HS256", "typ": "JWT" }. - Payload: the data, called claims, such as the user ID, roles and expiry time.
- Signature: proves the header and payload were created by someone with the secret or private key, and not changed since.
Base64URL is a variant of Base64 that uses - and _ instead of + and /, and usually leaves out the = padding, so the token is safe to use in URLs. You can encode and decode it with the Base64 tool (turn on URL-safe).
Decode a JWT online
Paste the token into the JWT Decoder. It shows the header and payload as formatted JSON, lists every claim with its meaning, converts timestamps to readable dates, and tells you whether the token has expired. A leading Bearer is removed automatically.
Tokens give access to accounts, so where you decode them matters. The JsonStage decoder runs entirely in your browser and never sends the token anywhere. Avoid pasting production tokens into tools that send them to a server.
Standard claims explained
| Claim | Name | Meaning |
|---|---|---|
iss | Issuer | Who created the token, usually your auth server's URL |
sub | Subject | Who the token is about, usually the user ID |
aud | Audience | Which application or API the token is meant for |
exp | Expiration time | After this moment the token must be rejected |
nbf | Not before | The token is not valid before this moment |
iat | Issued at | When the token was created |
jti | JWT ID | A unique ID, useful for blocking a single token |
exp, nbf and iat are seconds since January 1, 1970 (Unix time), not milliseconds. In JavaScript, multiply by 1000: new Date(payload.exp * 1000). Many "my token expired immediately" bugs come from mixing these up.
Decode a JWT in code
// Node.js
const payload = JSON.parse(Buffer.from(token.split('.')[1], 'base64url').toString())
// Browser (works with non-English characters too)
function decodePart(part) {
const b64 = part.replace(/-/g, '+').replace(/_/g, '/')
const bytes = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0))
return JSON.parse(new TextDecoder().decode(bytes))
}
const payload2 = decodePart(token.split('.')[1])import base64, json
def decode_part(part: str) -> dict:
padded = part + "=" * (-len(part) % 4) # restore padding
return json.loads(base64.urlsafe_b64decode(padded))
payload = decode_part(token.split(".")[1])Decoding is not verifying
"role": "admin" in the payload. Only the signature proves it came from your auth server.On the server, always use a maintained library that verifies the signature, the expiry and the expected algorithm in one step:
- Node.js:
joseorjsonwebtoken - Python:
PyJWT - Most other languages have an equivalent; check jwt.io's library list
Set the allowed algorithms explicitly. Old libraries accepted "alg": "none" (no signature at all), which allowed forged tokens.
Practical tips
- Don't put secrets in the payload. It is readable by anyone who sees the token: in browser storage, in logs, in proxies. (Encrypted tokens, called JWE, have five parts instead of three.)
- Keep tokens short-lived. A small
explimits the damage if a token leaks. - Debugging "401 Unauthorized"? Decode the token and check
exp(expired?),aud(meant for this API?) andiss(issued by the right server?). Those three explain most rejected tokens.