JWTs explained: what is inside a token and what decoding proves
Updated 11 October 2026 · 5 min read
jwtsecurityauthenticationdeveloper
A JSON Web Token (JWT) is a compact string that carries a few facts about a user or a request, such as who they are, who issued the token and when it stops being valid. Servers hand them out after login, and clients send them back in an Authorization: Bearer header. Because the string looks like random noise, many people assume it is encrypted. It almost never is.
This guide explains the three parts of a JWT, what the common claims mean, how signatures work at a conceptual level, and the mistakes that cause real security bugs. It ends with a worked example you can reproduce, because reading a token by hand is the quickest way to understand it.
Three parts joined by dots
A signed JWT is three pieces separated by dots: header.payload.signature. The header and payload are JSON objects, each encoded with Base64URL. The signature is raw bytes, also Base64URL-encoded.
Base64URL is ordinary Base64 with - and _ instead of + and /, and with the trailing = padding left off, so the token is safe inside a URL or header. It is an encoding, not a cipher. Anyone holding the token can turn the first two parts back into readable JSON without any key, which is why a base64 decoder is enough to read a payload.
The header says how the token is signed, for example {"alg":"HS256","typ":"JWT"}. The payload holds the claims. A token with five dot-separated parts is a different thing, an encrypted JWE, and cannot be read this way.
The claims you will see most often
The payload can contain any JSON, but a handful of names are registered by the JWT standard:
iss: the issuer, usually the URL of the service that created the token.sub: the subject, normally a stable user ID rather than an email address.aud: the audience, meaning which API the token is meant for. A service should reject tokens addressed to someone else.exp: the expiry time. After this moment the token must be refused.nbf: not before. The token is not valid until this time.iat: issued at, the moment the token was created.
The three time claims are whole seconds since 1 January 1970 UTC (Unix time), not milliseconds. A value like 1760144400 is in seconds; multiply by 1000 before giving it to JavaScript's new Date(). Mixing up seconds and milliseconds is the most common reason an expiry looks like it is in 1970 or in the year 57000.
How the signature works
The signature is computed over the exact text base64url(header) + "." + base64url(payload). If anyone changes a single character of the payload, the signature no longer matches, and a verifier will notice. That is the whole point: the token is tamper-evident, not secret.
With HS256 (HMAC with SHA-256), the issuer and the verifier share one secret key. The same key creates and checks the signature. It is simple and fast, and fine when one service both issues and verifies tokens. The downside is that every service able to verify a token could also forge one.
With RS256 (RSA with SHA-256), the issuer signs with a private key and publishes a public key. Anyone can verify, but only the holder of the private key can create valid tokens. This suits setups where an identity provider issues tokens and many separate APIs check them.
Neither option hides the payload from the person carrying the token.
What decoding shows, and what it cannot prove
Decoding only reverses the Base64URL step and parses the JSON. It tells you what the token claims. It does not tell you the claims are true, because anyone can write {"sub":"admin"}, encode it and paste it after two dots.
Only signature verification, using the right key and an expected algorithm, shows that the token came from the issuer and was not modified. A decoder in your browser, including the one on this site, has no key and does not check the signature. Use it to inspect and debug, never as proof that a token is genuine.
Verification is also not the end. A correctly signed token still has to be checked for exp, nbf, the right iss and the right aud.
Mistakes that cause real incidents
- Putting secrets in the payload. Passwords, API keys and private data are readable by anyone who sees the token, including in logs and browser storage.
- Trusting a token without verifying it. Reading
subfrom a decoded payload and acting on it is the same as trusting whatever the client typed. - Accepting
alg: none. The standard defines an unsigned token type, and some older libraries accepted it when it appeared in the header. Fix the allowed algorithms on the server instead of obeying the header. - Very long expiry. A token valid for a year cannot be taken back if it leaks. Short-lived access tokens plus a refresh mechanism limit the damage.
- Ignoring
audandiss, so a token issued for one service is accepted by another.
Worked example: reading a fake token
Here is a deliberately fake token, built for this guide. It signs nothing real and its signature is just the text "fake-signature-not-real" encoded:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyLTEyMyIsImlzcyI6Imh0dHBzOi8vYXV0aC5leGFtcGxlLnRlc3QiLCJhdWQiOiJkZW1vLWFwaSIsImlhdCI6MTc2MDE0MDgwMCwibmJmIjoxNzYwMTQwODAwLCJleHAiOjE3NjAxNDQ0MDB9.ZmFrZS1zaWduYXR1cmUtbm90LXJlYWw
Run through this site's decoder code, the header comes out as {"alg":"HS256","typ":"JWT"}. The payload is {"sub":"user-123","iss":"https://auth.example.test","aud":"demo-api","iat":1760140800,"nbf":1760140800,"exp":1760144400}.
The time claims convert to 2025-10-11 00:00:00 UTC for iat and nbf, and 01:00:00 UTC for exp. The lifetime is exp - iat = 3600 seconds, one hour. Checked at 02:00 UTC that day, the decoder reports the token as expired; checked at 00:30 UTC it does not.
Debugging an expired token
When an API answers 401 and you suspect expiry, decode the token and compare exp with the current time. If it is in the past, the fix is to refresh or log in again, not to change anything on the server.
If exp looks fine, look at nbf: a token used a few seconds before its not-before time fails too, and a client clock running ahead of the server by a minute or two is a frequent cause. Many verifiers allow a small clock tolerance for this reason.
If the dates look absurd, check whether a service wrote milliseconds where seconds belong. A Unix timestamp converter makes that obvious in a moment.
Frequently asked questions
Is a JWT encrypted?
A normal signed JWT is not. The header and payload are Base64URL-encoded, which anyone can reverse. The signature protects against changes, not against reading. Encrypted tokens exist (JWE, five parts) but are much less common.
Is it safe to paste a JWT into an online decoder?
Treat a live token like a password, because anyone holding it can use it until it expires. The decoder on this site works in your browser without uploading anything, but the safest habit is to decode tokens from test environments or expired ones.
What is the difference between HS256 and RS256?
HS256 uses one shared secret to both sign and verify. RS256 signs with a private key and verifies with a public key, so verifiers cannot forge tokens. Pick RS256 when several services verify tokens issued elsewhere.
Why does my exp date show 1970?
The value was probably read as milliseconds when it is in seconds, or the claim is missing and defaulted to zero. JWT time claims are seconds since 1 January 1970 UTC.