JWT Explained: Header, Payload, Signature — and Decoding vs Verifying
How a JSON Web Token is structured, what the standard claims mean, and the crucial difference between decoding a token and verifying it.
A JSON Web Token (JWT) is a compact way to carry claims — statements like 'this user is admin' or 'this token expires at 5pm' — between systems. It's widely used for authentication, and it's widely misunderstood in one specific, security-critical way.
Three parts, dot-separated
A signed JWT has three segments joined by periods: header, payload, and signature. Each of the first two is a JSON object encoded with Base64URL.
- Header — which algorithm signed the token (e.g. HS256) and the type.
- Payload — the claims: the actual data being carried.
- Signature — proof the first two parts weren't tampered with.
eyJhbGciOiJIUzI1NiJ9 . eyJzdWIiOiJBMTIzIn0 . <signature>The payload and standard claims
The payload holds claims. Some are registered, meaning they have agreed-upon names and meanings:
- exp — expiry time (seconds since the epoch). After this the token should be rejected.
- iat — issued-at time.
- iss — issuer, who created the token.
- sub — subject, usually the user identity.
- aud — intended audience.
- nbf — not-before; the token isn't valid until this time.
Decoding is not verifying
This is the part that causes real bugs. The header and payload are only Base64URL-encoded, not encrypted — anyone can read them. Decoding a JWT reveals its contents instantly and requires no secret at all.
Verification is different: it recomputes the signature using the issuer's secret (HMAC) or public key (RSA/ECDSA) and checks it matches. Only verification proves the token wasn't altered and was really issued by who it claims.
A decoder lets you inspect a token you already trust. It must never be used as a substitute for signature verification in your backend — a token can be trivially forged by editing the payload and skipping the signature.
Inspecting a token safely
Because a token can grant access, only decode tokens that were issued to you.
- 1Paste the token into a JWT decoder to read the header and payload.
- 2Check the exp claim to see whether it has expired.
- 3Treat the contents as untrusted until a server verifies the signature.
- 4Never paste a live token you don't own into a third-party site.

