← Lessons/Anatomy of a JWT
← Anatomy of a JWT

Three parts, split by dots

Learn

Three segments, two dots

xxxxx.yyyyy.zzzzz
header.payload.signature

Each segment is base64url-encoded (the URL-safe base64 from lesson 1: - and _ instead of + and /, padding stripped).

  1. Header: JSON describing the token, mainly alg (the signing algorithm) and typ. Often there's also a kid (key ID) saying which key signed it.
  2. Payload: JSON claims, the facts the token asserts.
  3. Signature: the bytes of HMAC-SHA256(key, base64url(header) + "." + base64url(payload)) for HS256, or a public-key signature for RS256/ES256/EdDSA.

cut -d. -f1 takes the first segment. The header usually decodes with plain base64 -d.

A JWT is three base64url segments joined by .. Print the decoded header: the first segment of $token, base64-decoded.

$ bash solution.sh
Loading...

Output

Run your solution to see its output here.