What Is a JSON Web Token (JWT)?
A JSON Web Token (JWT) is a compact, URL-safe string that represents claims between two parties. Defined by RFC 7519, a JWT consists of three Base64url-encoded parts separated by dots: a header specifying the algorithm and token type, a payload containing the claims (user data, permissions, expiration), and a signature ensuring the token hasn't been tampered with.
JWTs are the backbone of modern authentication. OAuth 2.0, OpenID Connect, and most API authentication systems use JWTs to pass identity and authorization data between services. Unlike session cookies, JWTs are stateless — the server doesn't need to store session data, making them ideal for microservices and distributed architectures.
How to Decode a JWT
Decoding a JWT is straightforward because the header and payload are simply Base64url-encoded JSON — not encrypted. Paste any token starting with eyJ into the input field and the decoder instantly splits it into its three parts. The header reveals the signing algorithm (HS256, RS256, etc.) and token type. The payload shows all claims with timestamps automatically converted to human-readable dates and relative time. Special claims like exp, iat, and sub are labeled for quick understanding.
Remember: decoding is not the same as verifying. Anyone can read a JWT's contents without the secret key. The signature exists to prove the token wasn't modified, but verifying it requires the signing key and is typically done server-side.
Understanding JWT Claims
JWT claims are the key-value pairs in the payload. The specification defines seven registered claims: iss (issuer), sub (subject), aud (audience), exp (expiration), nbf (not before), iat (issued at), and jti (JWT ID). Beyond these, applications add custom claims for roles, permissions, email, and other user attributes. This decoder highlights registered claims with labels and timestamps while distinguishing custom claims visually.
JWT Security Best Practices
Always set short expiration times (exp) and use refresh tokens for long-lived sessions. Never store sensitive data in the payload since it is only encoded, not encrypted. Validate the alg header server-side to prevent algorithm confusion attacks. Use RS256 over HS256 when the token is verified by multiple services. Store JWTs in httpOnly cookies rather than localStorage to mitigate XSS attacks. Always reject tokens with alg: "none" in production.