What a JSON Web Token is
A JSON Web Token (JWT, RFC 7519) is a compact way to pass a set of claims from one party to another. A claim is a single statement, such as who the user is, who issued the token, or when it stops being valid.
Most JWTs you meet are signed, not encrypted. The signature lets the receiver check who issued the token and that nobody changed it. It does not hide anything. Anyone who holds a signed token can read every claim in it.
Identity providers such as Keycloak issue JWTs as access tokens and ID tokens. Your apps and APIs read them on every request, so being able to look inside one quickly saves a lot of guessing.
How decoding works
A signed JWT in compact form is three parts joined by dots: a header, a payload and a signature. The header and payload are JSON, encoded with Base64url. The signature is raw bytes, also Base64url-encoded.
| Part | Contains | Readable? |
|---|---|---|
| Header | The algorithm (alg), the key id (kid), the type (typ) | Yes, it is JSON |
| Payload | The claims: issuer, subject, audience, times, roles | Yes, it is JSON |
| Signature | Bytes computed over the first two parts with a key | No, it is binary |
Decoding means splitting on the dots, turning each Base64url part back into bytes, and reading the bytes as UTF-8 JSON. No key is involved, which is why any tool, including this one, can do it.
const [header, payload] = token.split('.');
const json = (part) =>
JSON.parse(new TextDecoder().decode(
Uint8Array.from(atob(part.replace(/-/g, '+').replace(/_/g, '/')), (c) => c.charCodeAt(0)),
));
console.log(json(header), json(payload));What this decoder shows, and what it does not
The decoder shows the header and payload as formatted JSON, the signing algorithm and key id as badges, and every time claim as a date with how long ago or from now it is. It tells you at a glance whether the token has expired.
It does not check the signature. A token whose payload someone edited by hand decodes just as cleanly as a genuine one. To know a token is real, check its signature with the signature verifier, then check its claims with the claims validator.
It also cannot read encrypted tokens. Those have five parts instead of three, and their payload is ciphertext. The JWE header inspector shows what can be read from them.
How to decode a token
- Copy the token from where your app keeps it: an
Authorizationheader in your browser’s network tab, a log line, or a test. - Paste it into the box. The word
Bearerin front is fine; it is removed before decoding. - Read the header badges for the algorithm and key id.
- Read the payload for the issuer, audience, subject, roles and scopes.
- Check the expiry line and the list of time claims.
The page decodes as you type, so you can also edit a token to see where it breaks. Nothing you paste leaves your browser.
Reading the header
The header says how the token was signed. Three fields matter most.
alg: the signing algorithm.RS256is an RSA signature with SHA-256,ES256an elliptic-curve signature,HS256an HMAC with a shared secret.nonemeans the token is not signed at all and must be rejected.kid: the id of the key that signed the token. A verifier uses it to pick the right public key from the issuer’s key set.typ: the media type of the token, usuallyJWT. Some issuers useat+jwtfor access tokens (RFC 9068).
Fields such as jku, x5u or jwk in the header point to or carry a key. A verifier should not trust a key that the token supplies about itself; the security checker flags these.
Reading the payload
RFC 7519 registers a small set of claim names. Everything else is defined by the issuer.
| Claim | Meaning |
|---|---|
iss | Issuer: who created and signed the token |
sub | Subject: who the token is about, usually a user id |
aud | Audience: who the token is meant for; a string or a list |
exp | Expiry time, in seconds since 1970 |
nbf | Not before: the token is not valid earlier than this |
iat | Issued at: when the token was created |
jti | A unique id for this token |
Claims Keycloak adds
A Keycloak access token also carries azp (the client that asked for the token), typ (Bearer for access tokens, ID for ID tokens), scope, sid (the session), realm_access.roles (realm roles), resource_access (client roles, by client id) and user details such as preferred_username, depending on the client scopes the client uses.
The issuer has the form https://<host>/realms/<realm>. If you run several realms, the last part of iss tells you at once which realm issued a token. The token roles viewer lays out the role claims client by client.
Times in a token
JWT times are Unix seconds in UTC, not milliseconds. A value such as 1764000000 is a moment in late 2025. If a number has 13 digits, it is milliseconds and the issuer made a mistake, or you are looking at something other than a JWT claim.
The decoder shows exp, iat, nbf, auth_time and updated_at as dates in UTC and in your local time. For a timeline with a live countdown, use the expiry checker; to convert a single value, use the Unix timestamp converter.
Where decoding helps
Most token problems are visible in the claims long before you need a debugger.
A request fails with 401 or 403
Decode the token the client sent. Check that exp is in the future, that iss is the issuer your API trusts, and that aud names your API. A token for the wrong realm, the wrong environment or the wrong audience looks fine until you read it.
A user is missing a permission
Look at realm_access.roles and resource_access. If the role is not in the token, your API cannot see it, whatever the admin console shows. The cause is often a client scope or a scope mapping, not the user.
Two environments behave differently
Decode a token from each and compare them with the JWT compare tool. Differences in issuer, audience, mappers or lifetime usually explain the difference in behavior.
Writing tests and documentation
Decoding a real test token shows the exact shape your code must handle: whether aud is a string or a list, which claims are present, and how roles are nested.
Access, ID and refresh tokens in Keycloak
Keycloak issues three kinds of token in the OpenID Connect flows, and they are meant for different readers.
| Token | `typ` claim | Meant for |
|---|---|---|
| Access token | Bearer | Your APIs, sent in the Authorization header |
| ID token | ID | The client app, to learn who signed in |
| Refresh token | Refresh or Offline | Keycloak only, to get new tokens |
You can decode all three, but treat the refresh token as opaque in your own code. Keycloak signs it with a realm secret it does not publish, so only Keycloak can check it.
Common decoding errors
“A JWT has 3 parts”
The text has too few or too many dots. Copying from a log often cuts the token short or joins it to the next field. Copy it again from the source.
“This is an encrypted token”
The token has five parts, so it is a JWE. Its claims cannot be read without the recipient’s private key.
“Not Base64url-encoded JSON”
A part contains characters outside the Base64url alphabet, often a stray quote, a space or a line break added by an email client or a terminal. Opaque tokens, which some servers issue instead of JWTs, also fail here because they are not JWTs at all.
What is safe to paste
This page decodes in your browser and sends nothing to us. Even so, a live access token works for anyone who holds it until it expires. Prefer tokens from a test realm, or expired ones.
Never paste refresh tokens or offline tokens from production into any website. They can live for days or longer and can be exchanged for new access tokens.
Decoding is not verification. A decoded token tells you what it claims, not whether those claims are true.
Best practices
- In your API, always verify the signature with keys you fetched from the issuer, then check
exp,issandaud. - Never make access decisions from a token you only decoded.
- Keep tokens out of URLs and logs. If you must log one, log its
jtior a hash instead. - Keep access tokens short-lived and refresh them, rather than issuing long-lived ones.