JSON Web Tokens are everywhere — login flows, API auth, service-to-service calls — and most developers’ mental model stops at “the thing in the Authorization header”. That’s fine until a token expires unexpectedly, a claim is missing, or someone pastes a production token into a random website to debug it. This guide explains what’s actually inside a JWT and how to inspect one safely.
Need to look inside a token right now? The JWT Decoder runs entirely in your browser — the token is never uploaded, which matters more than you might think (more on that below).
Three parts, two dots
A JWT is three Base64URL-encoded segments joined by dots:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 . eyJzdWIiOiIxMjM0NTY3ODkwIiwiaWF0IjoxNTE2MjM5MDIyfQ . SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
header payload signature
Base64URL is encoding, not encryption. Anyone who holds the token can read the header and payload. This is the single most important fact about JWTs: never put secrets, passwords, or sensitive personal data in the payload.
The header
{ "alg": "HS256", "typ": "JWT" }
alg declares the signing algorithm: HS256 (HMAC with a shared secret), RS256 (RSA signature), ES256 (elliptic curve), or none (unsigned — which your verifier must always reject).
The payload (claims)
{
"sub": "1234567890",
"name": "John Doe",
"iat": 1516239022,
"exp": 1516242622
}
Claims are statements about the subject. RFC 7519 defines seven registered ones you’ll see constantly:
| Claim | Meaning | Notes |
|---|---|---|
iss | issuer | who minted the token |
sub | subject | who the token is about (user ID) |
aud | audience | who the token is for — verify it! |
exp | expiration | Unix seconds; reject after this |
nbf | not before | reject before this |
iat | issued at | Unix seconds |
jti | JWT ID | unique ID, useful for revocation lists |
All timestamps are seconds since epoch, not milliseconds — a classic source of “my token expires in 1970” bugs. If you’re converting them by hand, the timestamp converter auto-detects seconds vs milliseconds.
The signature
The signature is computed over header.payload using the algorithm and key. It proves the token wasn’t modified and was minted by someone holding the key. Critically:
- Decoding ≠ verifying. Reading the payload requires nothing. Trusting it requires checking the signature with the right key.
- Verification needs the secret (HS256) or public key (RS256/ES256) — which is exactly why you should never paste a signing secret into any online tool, including ours. Our decoder deliberately shows the signature but never verifies it.
Why “paste your token here” sites are risky
A JWT in the wild is usually a live credential: whoever holds it can act as you until it expires. Pasting a production token into a third-party website means trusting that site’s servers, logs, and analytics with your session. Many popular decoders do the decoding server-side.
The safe pattern is client-side decoding — the token never leaves the machine. That’s how the JWT Decoder on this site works (you can verify in your browser’s network tab: zero requests after page load). For production tokens, prefer a local tool or a decoder you can audit.
Expiry and clock skew in practice
Most “invalid token” bugs are one of four things:
- Expired (
expin the past). Check the claim against the current time. The decoder flags expired tokens automatically. - Clock skew. The issuer’s clock is 30 seconds ahead of the verifier’s, so a fresh token is “not yet valid” (
nbf) or already expired. Verifiers should allow a small leeway (typically ≤60s). - Wrong audience. The token was minted for a different service.
audmismatches must be rejected — accepting them lets tokens leak across services. - Milliseconds vs seconds. Someone wrote
Date.now()intoexpinstead ofDate.now()/1000. The token now expires in the year 55,000 — or was built with seconds and expires instantly on a verifier expecting ms.
A minimal verification checklist (server side)
Whatever library you use, ensure it:
- Rejects
alg: noneand algorithm confusion (an RS256-expecting verifier must not accept an HS256 token signed with the public key as the HMAC secret). - Pins the expected algorithm(s) explicitly instead of trusting the header’s
alg. - Validates
exp,nbf,iss, andaud— not just the signature. - Uses a maintained library (
jose,jsonwebtoken,PyJWT,golang-jwt) rather than hand-rolled crypto.
Storing tokens in browsers: the short version
localStorageis readable by any XSS payload. If your threat model includes XSS (it does), preferHttpOnlycookies for session tokens.- Keep access tokens short-lived (minutes) and use refresh tokens for longevity.
- Never put a JWT in a URL query string — URLs land in logs, referrers, and browser history.
Recap
- A JWT is
header.payload.signature, Base64URL-encoded — readable by anyone, trustworthy only after signature verification. - Claims like
exp,nbf,aud,issare the contract; verify all of them. - Timestamps are seconds; allow small clock skew.
- Decode locally, never paste production tokens or secrets into server-side tools.
With that model, a JWT stops being a magic string and becomes what it actually is: a signed, self-describing envelope of claims you can inspect in seconds with the JWT Decoder.