DeveloperMar 21, 2026 Β· Updated Oct 13, 2026 Β· 4 min read

How to Decode a JWT Token (Without the Secret)

JWTs are encoded, not encrypted β€” anyone can read the payload without the secret key. Decoding a JWT is essential for debugging authentication issues, inspecting token claims, and verifying that tokens contain the expected data. The secret is only needed to verify the signature, not to read the contents.

πŸ”‘
Try the JWT Decoder
Free, no signup
β†’
DG
Derek Giordano
Designer & Developer
In this guide
01Decoding a JWT Manually02Decoding in JavaScript (Correctly)03Worked Example: The Common One-Liner vs a UTF-8 Decoder04What to Look for in a Decoded JWT05Decoding vs Verifying

Decoding a JWT Manually

A signed JWT (the usual kind, a JWS in compact form) has three parts separated by dots: header, payload and signature. The first two are JSON encoded as Base64URL β€” Base64 with - and _ instead of + and /, and with the trailing = padding removed (RFC 7515). To read one:

1. Split the token at the dots. Three parts means a signed token; five parts means an encrypted token (JWE, RFC 7516), whose payload you cannot read without the key.

2. Base64URL-decode the header. It names the algorithm (alg), usually the type (typ) and often a key ID (kid).

3. Base64URL-decode the payload to get the claims.

4. Leave the signature alone: it is raw bytes, and it only means something when you check it with the right key.

Decoding in JavaScript (Correctly)

The one-liner that circulates β€” JSON.parse(atob(part.replace(/-/g, '+').replace(/_/g, '/'))) β€” works for plain ASCII claims and breaks on everything else, because atob() returns each byte as one character instead of decoding UTF-8. Decode the bytes as UTF-8 explicitly and restore the padding:

function decodePart(part) { let b64 = part.replace(/-/g, '+').replace(/_/g, '/'); b64 += '='.repeat((4 - b64.length % 4) % 4); const bytes = Uint8Array.from(atob(b64), c => c.charCodeAt(0)); return JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes)); } function decodeJWT(token) { const [header, payload] = token.split('.'); return { header: decodePart(header), payload: decodePart(payload) }; }

In Node.js, Buffer.from(part, 'base64url').toString('utf8') does the same in one call.

Worked Example: The Common One-Liner vs a UTF-8 Decoder

We built three test tokens and decoded the name claim with both functions (Node.js with browser atob semantics; script in our test folder, October 13, 2026):

Claim in the tokenatob one-linerUTF-8 decoder above
AnaAnaAna
JosΓ© MΓΌllerJosé MüllerJosΓ© MΓΌller
Rocket πŸš€Rocket Γ° followed by three unprintable charactersRocket πŸš€

Any name, address or company claim outside ASCII is garbled by the one-liner. Our JWT Decoder had the same bug until October 2026; it now decodes UTF-8 and flags unsigned (alg: none) tokens and millisecond timestamps.

What to Look for in a Decoded JWT

The registered claims are defined in RFC 7519: iss (issuer), sub (subject, usually a user ID), aud (audience), exp (expiry), nbf (not valid before), iat (issued at) and jti (token ID). The three time claims are NumericDate values β€” seconds since 1970-01-01 UTC, not milliseconds β€” so a 13-digit exp is a bug in whatever issued the token. A token is usable only when the current time is at or after nbf and before exp; allow a small clock-skew margin of a minute or two, not hours.

Decoding vs Verifying

Decoding reads the claims; it proves nothing about them. Anyone can create a token with any payload. Before trusting one, verify it server-side with a maintained library, and follow the JWT Best Current Practices (RFC 8725): accept only the algorithms you expect instead of trusting the token's own alg header (which is how alg: none and RSA/HMAC key-confusion attacks work), check iss and aud, and validate exp and nbf. And remember that a signed JWT is readable by anyone who holds it β€” never put secrets or personal data in it that the holder should not see.

Frequently Asked Questions

Can I decode a JWT without the secret key?+
Yes, for the usual signed tokens (JWS): the header and payload are only Base64URL-encoded, so anyone can read them; the key is needed to verify the signature. Encrypted tokens (JWE, five dot-separated parts) are different β€” their payload cannot be read without the decryption key.
How do I check if a JWT is expired?+
Decode the payload and read exp, a NumericDate in seconds since 1970-01-01 UTC. The token is expired when the current time in seconds is at or after exp; also check nbf (not valid before). Allow a small clock-skew margin, typically a minute or two.
Is it safe to decode JWTs in the browser?+
Yes, for inspection purposes. Decoding just reads the payload β€” it doesn't expose the signing secret. But never make authorization decisions based on a decoded-but-unverified token.
Try it yourself

Use the JWT Decoder β€” free, no signup required.

⚑ Open JWT Decoder
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.