← Lessons

quiz vs the machine

Gold1340

System Design

JWT Structure and Claims

The three parts of a JSON web token and why signing not hiding is the point.

5 min read · core · beat Gold to climb

Three base64 parts

A JSON web token is three base64url encoded sections joined by dots:

  • The header, naming the signing algorithm.
  • The payload, holding the claims.
  • The signature, computed over the header and payload.

Claims

The payload carries claims about the subject. Standard registered claims include iss issuer, sub subject, aud audience, exp expiry, and iat issued at. Applications add custom claims like roles, but should keep tokens small.

Signed, not encrypted

A crucial point: a standard signed JWT is not encrypted. Anyone can base64 decode the payload and read it, so secrets must never be placed inside. The signature only guarantees integrity: it proves the token was not altered and was issued by a holder of the signing key.

Servers must verify the signature and the claims, especially exp and aud. Accepting an unverified token, or trusting the header's algorithm field blindly, is a well known vulnerability.

Key idea

A JWT is a signed header, payload, and signature; the signature guarantees integrity, not secrecy, so the readable payload must hold no secrets.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a standard signed JWT guarantee about its payload?

2. Why should secrets never be placed in a JWT payload?

3. Which claim should the server always check to reject stale tokens?