Card 06/ 12
JWT: Header, Payload and Signature
A JWT is three base64url parts joined by dots, and the signature proves the first two were not changed.
A JSON Web Token, or JWT, is a token made of three parts joined by dots: a header naming the signing algorithm, a payload of claims about the caller, and a signature over the first two. Each part is base64url, a URL-safe encoding of bytes as text. A server that holds the issuer's key can check the signature and trust the claims without looking anything up, which is what makes a JWT self-contained.
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjIwMjYtMTAifQ
.eyJpc3MiOiJodHRwczovL2F1dGguZXhhbXBsZS5jb20iLCJzdWIiOiJ1c2VyXzgzNDEiLCJhdWQiOiJodHRwczovL2FwaS5leGFtcGxlLmNvbSIsImV4cCI6MTc5MTM3MDgwMCwiaWF0IjoxNzkxMzY3MjAwLCJzY29wZSI6Im9yZGVyczpyZWFkIn0
.kH3w9Qe1... (signature, shortened)
Header:
{ "alg": "RS256", "typ": "JWT", "kid": "2026-10" }
Payload:
{
"iss": "https://auth.example.com",
"sub": "user_8341",
"aud": "https://api.example.com",
"exp": 1791370800,
"iat": 1791367200,
"scope": "orders:read"
}The header. alg is the signing algorithm, here RS256, an RSA signature with SHA-256. kid, the key id, names which of the issuer's keys signed it.
The registered claims. RFC 7519 defines short names:
iss, the issuer, who created the token.sub, the subject, who the token is about, usually the user.aud, the audience, which API the token is for.exp, the expiry, andnbf, not before, as seconds since 1970.iat, when it was issued, andjti, a unique token id.
Here the token expires at 11:00 UTC on 7 October 2026, an hour after it was issued. Issuers add their own claims, such as scope.
The signature. It is computed over the encoded header and payload with the issuer's private key, or a shared secret for HMAC algorithms. Change one character of the payload and the signature no longer matches.
Where it travels and who it suits. As a bearer token in Authorization. It suits services that must verify callers without calling the issuer each time, and its weakness is the cut-off: until it expires, nothing in it changes.
← → move through sections and cards