Guide
Anatomy of a JSON Web Token
By Logappradeep · ServiceNow developer
A JWT looks like a random string, but it has a precise structure defined by RFC 7515 (JSON Web Signature) and RFC 7519 (JSON Web Token). This parser breaks a token into its parts as you type, color-codes each segment in the original string, and decodes the readable ones, which makes it a useful learning aid as well as a debugging tool.
The compact serialization
A signed JWT is three Base64URL strings joined by dots:
xxxxx.yyyyy.zzzzz
header.payload.signature
- Header (red): a JSON object describing how the token is secured.
- Payload (purple): a JSON object containing the claims.
- Signature (blue): raw bytes produced by signing
header.payload, encoded as Base64URL.
The dots are not encoded and never appear inside a segment, which is why splitting on them is safe.
Why so many tokens start with "eyJ"
Every header and payload is a JSON object, so it begins with {". Those two bytes always encode to eyJ in Base64URL. Spotting eyJ in a header, cookie, or log line is a reliable hint that you are looking at a JWT, and if you see it twice in one string, separated by a dot, you almost certainly are.
Base64URL, not plain Base64
JWTs travel in URLs, HTTP headers, and cookies, so they use the URL-safe alphabet from RFC 4648: - replaces +, _ replaces /, and trailing = padding is removed. A standard Base64 decoder may reject a segment until those characters are swapped back and the padding is restored. The parser handles that conversion for you.
Header parameters you will see
alg: the signing algorithm, such as HS256, RS256, or ES256.typ: usuallyJWT; some specifications use values such asat+jwtfor access tokens.kid: a key ID that tells the verifier which key from a key set to use, which is essential for key rotation.cty: content type, used when a JWT is nested inside another.
Variations to recognize
- Five segments means an encrypted JWE token (header, encrypted key, IV, ciphertext, authentication tag). Its payload cannot be read without the decryption key.
- An empty third segment means an unsecured token with
alg: none. Servers should reject these. - Size matters. Every claim adds bytes to every request. Large tokens can exceed header size limits on proxies or the roughly 4 KB limit for a single cookie, so keep payloads lean.
Parsing runs as you type, entirely in your browser, and the token is never sent to a server.