What is a JWT and how does it work?
A JSON Web Token (JWT) is a compact string used to transmit information securely between a client and server. It looks like three base64url-encoded strings joined by dots — and that's exactly what it is.
- Header — the algorithm used to sign the token (e.g. HS256, RS256) and the token type (JWT)
- Payload — the claims: user ID, roles, expiry, issued-at, and any custom data the server wants to include
- Signature — a cryptographic hash of the header and payload, signed with a secret key. Verifying it proves the token hasn't been tampered with
Common JWT claims
- sub — subject (usually a user ID)
- iat — issued at (Unix timestamp of when the token was created)
- exp — expiry (Unix timestamp after which the token is invalid)
- iss — issuer (who created the token — your auth server's domain)
- aud — audience (intended recipient of the token)
- name, email, role — custom claims added by the application
Decoding vs verifying
Decoding a JWT just reads the base64url-encoded data — anyone can do it, no secret needed. The payload is not encrypted, only encoded. This is intentional: JWTs are designed to be readable, just not forgeable. Verification (checking the signature) proves the token came from your server and wasn't tampered with — that requires the secret key or public certificate. Use this tool to inspect token contents during development; never verify tokens client-side in production.