Taking apart the most famous JWT on the internet
Nearly every JWT tutorial uses the same token, so it makes a good one to take apart by hand: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c. Paste it into the box above as you read. The two dots split it into three parts, and each part is Base64url: ordinary Base64 with - and _ in place of + and /, and the = padding left off.
The first part, eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9, decodes to the 27 characters {"alg":"HS256","typ":"JWT"}. That is the header. It says the token is signed with HMAC-SHA256, which means the issuer and the checker share one secret. Every JWT starts with eyJ because every header starts with {", and that is how {" looks in Base64.
The second part decodes to {"sub":"1234567890","name":"John Doe","iat":1516239022}. These are the claims. sub is the subject, usually a user id. iat is "issued at", a count of seconds since 1 January 1970 UTC. 1516239022 seconds after that is 18 January 2018 at 01:30:22 UTC, which the page shows in your own time zone along with how long ago it was. There is no exp claim, so the status reads No expiry: this token never runs out, which a real issuer should almost never allow.
Notice what just happened. Nothing secret was needed to read any of that. Base64url is a spelling, not a lock, so whatever a server puts in the claims is visible to the user, to their browser extensions and to every log the token passes through. Put an id in a JWT, never a password, and check what your own tokens carry by pasting one here.
The third part is the signature: 32 bytes, 49f94ac7...c397 in hex, written in Base64url as SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c. It is the HMAC-SHA256 of the first two parts exactly as written, dots included, with the secret as the key. Open Verify signature and type your-256-bit-secret, the secret the tutorials use. The page computes the HMAC itself, compares, and says Signature verified. Change one character of the secret, or one character of the claims, and it says Signature does not match. That check is what a server does on every request, and it is the only reason a JWT can be trusted at all.
This also shows the difference between decoding and verifying. The decoder happily showed you John Doe before any secret was typed. A careless server that only decodes would accept a token in which someone edited sub to another user id. Verification is what catches that. Tokens signed with RS256, ES256 or EdDSA work the same way, except the check uses the issuer’s public key, which you can paste in PEM form, so anyone can verify while only the issuer can sign. Whichever you check, the token and the key stay in this page and are never sent anywhere.