How to Read a JWT (and Why Decoding Is Not Verification)

JWT structure explained: header, payload and signature, the claims worth checking, and why decoding a token proves nothing about its validity.

Published November 19, 2026 jwtsecuritydevelopers

A JWT looks like three random strings joined by dots. It is not random at all: the first two parts are Base64URL-encoded JSON that anyone can read in a browser, and the third part is a signature that only the issuer can produce.

That asymmetry is the source of most JWT mistakes. Reading a token is trivial; trusting it without verification is a security bug.

The three parts

A JWT has the shape header.payload.signature:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkFkYSIsImV4cCI6MTc2MzUxMDQwMH0.5rGZ0m8k...
  • Header — the signing algorithm (alg) and token type (typ).
  • Payload — the claims: who the user is, when the token expires, who issued it.
  • Signature — proof that the header and payload were produced by someone holding the key.

Decoding the first two parts gives you readable JSON:

{
  "alg": "HS256",
  "typ": "JWT"
}
{
  "sub": "1234567890",
  "name": "Ada",
  "exp": 1763510400
}

There is nothing encrypted here. The signature protects the token against modification, not against reading.

Base64URL, not Base64

JWT uses Base64URL, a variant of Base64 that replaces + with - and / with _, and usually drops the = padding. That makes the token safe to put in a URL, a header or a cookie without percent-encoding.

When you decode a segment by hand, remember to reverse those substitutions first. A token segment that contains - or _ will fail in a standard Base64 decoder that does not expect them.

Decoding is not verification

Anyone can decode a JWT. Verification is a different operation with three requirements:

  1. Recompute the signature using the algorithm named in the header and the issuer’s key.
  2. Compare it in constant time with the signature in the token.
  3. Check the claims — especially exp, nbf, aud and iss.

A decoded payload tells you what the token claims. Only a verified payload tells you what the issuer actually granted. Forgetting this turns your application into a system where anyone can mint an admin token by editing the payload and leaving the old signature in place.

A decoder in a browser is a debugging tool. It is fine to inspect a token there; it is not fine to use the result as an authorization decision.

Claims worth checking

ClaimMeaningWhy it matters
expExpiry time, in seconds since the epochReject expired tokens, with a small clock skew allowance
nbfNot valid beforeReject tokens used too early
iatIssued atUseful for debugging and for maximum token age
issIssuerEnsure the token came from the expected authority
audAudienceEnsure the token was meant for your service
subSubjectThe stable user or client identifier
scope / scpGranted permissionsAuthorize the request, not just authenticate it

Two claims deserve extra attention in reviews:

  • aud is often omitted, which lets a token issued for one service be replayed against another.
  • exp is sometimes checked with > instead of <, or not checked at all, which produces tokens that never expire.

Algorithm confusion

The alg field is attacker-controlled until the signature is verified. A server that trusts alg from the token can be tricked:

  • alg: "none" — some libraries historically accepted unsigned tokens.
  • alg: "HS256" when the server expects RS256 — a public key can be used as an HMAC secret in a confused verifier.

The rule is simple: the server chooses the allowed algorithms, not the token. Configure an explicit allowlist and reject everything else before touching the signature.

What should never be in the payload

The payload is readable by anyone who holds the token, including the user’s browser and any proxy or log that captures it.

Do not put in a JWT:

  • passwords or password hashes;
  • API keys, secrets or database credentials;
  • full personal data that the client does not already know;
  • large objects — tokens travel in headers, and headers have size limits.

Keep claims small and stable. If a client needs more profile data, fetch it from an API after authentication instead of packing it into the token.

Debugging a token

When a token fails, check in this order:

  1. Decode the header and payload and confirm the claims look right.
  2. Compare exp with the current time — remember it is in seconds, not milliseconds.
  3. Confirm aud and iss match what the service expects.
  4. Check which algorithm the verifier is configured to accept.
  5. Confirm the key or secret is the same one used to sign, including line breaks and trailing spaces.
  6. Look for whitespace or line wrapping introduced by a proxy or a copy-paste.

The JWT Decoder splits a token into header, payload and signature, converts timestamps into readable dates, and runs entirely in your browser. If you need to inspect a single segment, the Base64 tool decodes Base64URL as well. To compare two keys or fingerprints, the Hash Generator gives you a stable digest.

A practical checklist

  1. Verify the signature before reading any claim.
  2. Allowlist accepted algorithms on the server.
  3. Check exp, nbf, aud and iss on every request.
  4. Keep payloads small and free of secrets.
  5. Use short lifetimes and refresh tokens instead of long-lived access tokens.
  6. Treat browser decoders as debugging aids, never as authorization.

A JWT is a signed envelope, not a locked box. Once you treat the payload as public and the signature as the only proof, the design becomes much easier to reason about.

Tools mentioned in this article

Back to the blog