By Usama Farooq · Published 23 Nov 2026 · Updated 24 Nov 2026
How JWTs Work Under the Hood
A JSON Web Token (JWT) is a small signed package handed to you after login. It has three parts — a header, a payload and a signature — all base64url-encoded and joined with dots. Your browser sends it back with every request; the server checks the signature, and a match means trust without a database lookup.
The format is defined by RFC 7519, published by the Internet Engineering Task Force (IETF) in May 2015. Its authors — Michael Jones (Microsoft), John Bradley (Ping Identity), Nat Sakimura (NRI) — designed JWTs as a compact, URL-safe way to carry claims between two parties.
Try the free JWT Decoder
Paste any token into ToolsOfWeb’s JWT Decoder and read its header, payload and signature — free, no sign-up, and your tokens never leave your device.
What is a JWT?
A JWT is a URL-safe way to send a set of claims from one party to another, with proof the claims were not changed. A server creates one when you log in, and your browser sends it back with every request in an Authorization header. The server trusts it because the signature checks out, not because it remembers your session.
You have almost certainly used JWTs without noticing: log in to a modern web app and the response often includes a token of three long strings separated by dots. It is stored in memory or local storage and attached to later requests. The token carries its own proof, so the server keeps no session record — which is why JWTs suit APIs on many servers.
What are the three parts of a JWT?
Every JWT has three parts separated by dots: a header, a payload and a signature. The header names the signing algorithm and the token type. The payload carries the claims — statements about the user, such as who they are and when the token expires. The signature is a stamp that proves the two parts have not been tampered with.
A typical header:
{
"alg": "HS256",
"typ": "JWT"
}It says the token is signed with HS256. A typical payload:
{
"sub": "1234567890",
"name": "Usama",
"exp": 1796000000
}The sub claim identifies the user, and exp is the expiry time. Each part is base64url-encoded — base64 with + and / swapped for - and _ and the = padding dropped — so the token is safe in a URL or a header. The three parts are joined with dots.
RFC 7519 registers seven standard claims:
| Claim | Meaning |
|---|---|
| iss | Token issuer |
| sub | Token subject (the user) |
| aud | Intended audience |
| exp | Expiry (seconds since 1 January 1970) |
| nbf | Not valid before |
| iat | Issue time |
| jti | Token ID |
How is a JWT signed?
The signature is made by taking the encoded header and the encoded payload, joining them with a dot, and running that string through a signing algorithm with a secret key. With HS256, the common symmetric algorithm, that step is HMAC with SHA-256. Change one character in the header or the payload and the resulting signature no longer matches.
HS256 is symmetric: the same secret signs and verifies, so it must stay on the server. RS256 is the asymmetric alternative — the server signs with a private key, anyone verifies with the public key — the choice when several services check tokens but only one issues them. The free Hash Generator shows a SHA-256 digest — the same function at the heart of HS256.
How does a server verify a JWT?
The server splits the token on the dots, decodes the header and payload, then recomputes the signature from those two parts using its secret key. If the recomputed signature matches the one in the token, the token is genuine and untouched. If it does not match, or the token has expired, the server rejects the request.
Verification is four steps: split, decode, check expiry, recompute the signature. Notice what is missing: no database lookup. That is the whole point — the server trusts the signature alone, so a token works across servers sharing one secret key. The price is revocation: a valid token stays valid until it expires, so lifetimes stay short and refresh tokens issue new ones.
Why can anyone read a JWT's payload?
Because the header and payload are only encoded, not encrypted. Base64url is a way of writing bytes as text, not a way of hiding them — anyone who holds the token can decode it in seconds. The signature protects the token from being changed, but it does nothing to keep the contents secret.
That is the most misunderstood thing about JWTs. Decoding is not hacking — paste any token into the free JWT Decoder and you will see the header, payload and claims table, with expiry badges and unsigned-token warnings. Never put a password, an API key or anything private in a token — if the contents must stay secret, use an encrypted JWT (RFC 7516), not just a signature.
What happens when a JWT expires?
The exp claim holds an expiry time as seconds since 1 January 1970. When a server sees a token whose exp is in the past, it rejects the token, even if the signature is still valid. The user then has to log in again, or the app exchanges a longer-lived refresh token for a fresh access token.
Short lifetimes are deliberate: access tokens often last 15 minutes to an hour. The refresh token lives longer — days or weeks — in an HTTP-only cookie. The nbf claim marks a token not valid before a given time; iat records when it was issued. All three are plain numbers, so a decoded payload is easy to read — check them with the JSON Formatter.
When should you not use a JWT?
Do not use a JWT when you need to revoke access instantly, such as logging a user out of every device or banning an account. A token stays valid until it expires, and a server that never checks a database has no way to cancel it early. A session stored on the server is the better choice for that job.
JWTs fit when several services must trust one login without a shared session store — APIs, microservices and single sign-on are classic cases. They are the wrong tool when instant logout matters, when the token would carry sensitive data, or when sessions last so long that expiry stops helping. Pick the mechanism that matches the job — and remember: if you would not print it, do not put it in a token.
FAQs
No. A normal JWT is signed, not encrypted. The header and payload are base64url-encoded, which anyone can reverse in seconds, so the contents are readable by whoever holds the token. The signature only proves the token was not changed. If the contents must stay secret, use an encrypted JWT (JWE) instead.
Yes. Decoding needs no key at all — the header and payload are only encoded, so any decoder can show them. The secret key is needed only to verify the signature, which is what proves the token is genuine. That is why you can inspect a token freely but cannot forge a valid one without the key.
HS256 is the most common JWT signing algorithm. HS stands for HMAC, a way of combining a secret key with a message, and 256 is the SHA-256 hash function it uses. The server signs with a secret key and verifies with the same key. RS256 is the asymmetric alternative, signing with a private key and verifying with a public key.
Access tokens should be short-lived — 15 minutes to an hour is typical — so a stolen token stops working quickly. A separate refresh token, stored safely and lasting days or weeks, lets the app get a new access token without asking you to log in again. Never issue a token that lasts forever; an expiry is your safety net.
A session cookie is a random ID: the server looks it up in a database to find who you are. A JWT carries the identity itself, signed, so the server verifies it without a lookup. Sessions are easy to revoke instantly; JWTs scale better across many servers but stay valid until they expire.
Try the free JWT Decoder
Start with the JWT Decoder — paste a token and read its header, payload and signature free, no sign-up. Then read how I built the free PDF Merger for the same in-browser approach, and the password strength guide for the other half of login security.
