JSON Web Tokens look simple: three Base64URL chunks separated by dots. That simplicity hides several traps. Here are the ones I see most often.
1. Decoding is not verifying
Anyone can decode a JWT payload. Decoding only reads the claims; it does not prove the token is genuine. Always verify the signature on the server with the correct key before trusting any claim.
2. Using atob() on Base64URL
JWTs use Base64URL, which swaps + and / for - and _ and drops padding. Plain atob() fails on these tokens. Convert first:
function decodePart(part) { const b64 = part.replace(/-/g, "+").replace(/_/g, "/"); const padded = b64 + "=".repeat((4 - (b64.length % 4)) % 4); return JSON.parse(atob(padded)); } 3. Ignoring exp, nbf and iat units
These claims are in seconds since the epoch, not milliseconds. Compare against Date.now() / 1000, otherwise every token looks expired in the year 50000.
4. Accepting alg: none
Some libraries historically accepted unsigned tokens. Pin the allowed algorithms explicitly instead of trusting the header.
5. Storing secrets in the payload
The payload is readable by anyone who holds the token. Never put passwords, API keys or private data in it.
6. Pasting production tokens into random websites
A token is a credential. Use a decoder that runs entirely in your browser so nothing is uploaded.
Try it: JWT Decoder
Related: Base64 Decode and JSON Formatter. All 590+ tools at webdevtoolbox.com run client-side.