Websites and web tools
JWT decoders and how to optimize your tokens
A JSON Web Token (JWT) is a compact string that carries claims, such as who a user is and when their session ends. Decoders let you read one in seconds. This page explains what a decoder shows, the difference between decoding and verifying, and how to keep tokens lean for a customer portal or booking app.
Anatomy of a token
A signed JWT has three parts separated by dots: header, payload and signature. The header and payload are JSON encoded with Base64URL, which is Base64 with URL-safe characters and no padding. The signature is computed over the first two parts with a key.
| Part | Example content | Encoded length in this example |
|---|---|---|
| Header | {"alg":"HS256","typ":"JWT"}, 27 bytes | 36 characters |
| Payload | subject, role, iat, exp, 71 bytes | 95 characters |
| Signature | 32-byte HMAC-SHA256 value | 43 characters |
| Whole token | Three parts plus two dots | 176 characters |
Decoding is not verifying
Anyone can decode a JWT; the payload is encoded, not encrypted. A decoder that shows the claims tells you nothing about whether the token is genuine. Your server must verify the signature with the right key and check the claims before trusting it.
- Accept only the algorithms you expect; reject
noneand anything unexpected. - Verify the signature with the correct secret or public key.
- Check
exp(expiry) andnbf(not before), allowing a small clock skew. - Check
iss(issuer) andaud(audience) match your system. - Only then read the user's identity and role.
Optimizing token size
Tokens usually travel on every request in a header or cookie, so size adds up. Base64URL turns every 3 bytes into 4 characters.
- Keep only the claims the server needs to authorize a request: a subject id, a role, expiry.
- Look up profile details, such as name and vehicles, from the database when needed.
- Use short claim names that the standard already defines.
- Choose an algorithm with shorter signatures only if your security needs allow it.
Other good habits
- Keep access tokens short-lived, measured in minutes, and use refresh tokens for longer sessions.
- Do not put secrets or personal data in the payload; anyone holding the token can read it.
- Store tokens in cookies marked
HttpOnly,SecureandSameSitewhere your design allows. - Plan how to revoke access, since a valid JWT works until it expires.