Glossary

JWT

A JWT (JSON Web Token, RFC 7519) is a compact, URL-safe token made of three Base64URL-encoded segments separated by dots — header.payload.signature — used to carry claims (statements about a user or session) between parties, most commonly for authentication and authorization on the web.

How it works

The header and payload are each JSON objects, Base64URL-encoded (without padding). The header names the signing algorithm (alg, e.g. HS256 or RS256) and token type; the payload holds claims such as sub (subject), exp (expiry, a Unix timestamp), and any application-specific fields. The signature is computed over the encoded header and payload joined by a dot, using the algorithm named in the header — HMAC-SHA256 for HS256, or an RSA/ECDSA signature for RS256/ES256.

Critically, a JWT is signed, not encrypted, by default. Anyone can Base64URL-decode the header and payload and read the claims in plain text — the signature only proves the token wasn't tampered with (and, if verified against a trusted key, who issued it). Confidential data belongs in an encrypted token (JWE, RFC 7516), not a plain signed JWT (JWS, RFC 7515).

Example structure:

eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0In0.4pC1...
└──── header ────┘ └──── payload ────┘ └ signature ┘
{"alg":"HS256"}    {"sub":"1234"}

Common pitfalls

  • Never store sensitive data (passwords, secrets, full PII) in a JWT payload — it's readable by anyone who has the token.
  • The classic alg: "none" vulnerability: a server that trusts the algorithm named inside the token, rather than enforcing an expected algorithm, can be tricked into accepting an unsigned token as valid.
  • A JWT with a valid signature but an expired exp claim is still "correctly signed" — verifying the signature and checking expiry are separate steps, and skipping the second is a common bug.
  • Long-lived JWTs can't be revoked individually without extra infrastructure (a denylist or short expiry + refresh tokens), unlike a server-side session that can just be deleted.

Related terms

  • Base64 — the encoding (in its URL-safe form) used for the header and payload segments.
  • HMAC — the keyed-hash construction behind the common HS256 signing algorithm.
  • SHA-256 — the digest algorithm HMAC wraps in HS256.

See also

  • Tool: JWT Decoder — paste a token to see its decoded header, payload, and expiration status without leaving your browser.