Skip to content

JWT diff: compare two tokens

Paste two JWTs and see which header fields and claims were added, removed or changed, with time claims shown as dates.

Runs in your browser. Nothing you paste is sent to us.

Two sample tokens for the made-up realm acme are filled in: B is A after a refresh, with a role added.

Differences

5 differences

Header

No differences.

Payload

ClaimChangeToken AToken B
expchanged1764000300 2025-11-24T16:05:00Z (11/24/2025, 4:05:00 PM)1764000900 2025-11-24T16:15:00Z (11/24/2025, 4:15:00 PM)
iatchanged1764000000 2025-11-24T16:00:00Z (11/24/2025, 4:00:00 PM)1764000600 2025-11-24T16:10:00Z (11/24/2025, 4:10:00 PM)
jtichanged"7c1e2a9b-sample-0000-0000-000000000001""7c1e2a9b-sample-0000-0000-000000000003"
realm_access.roleschanged["default-roles-acme","offline_access","uma_authorization","order-manager"]["default-roles-acme","offline_access","uma_authorization","order-manager","billing-viewer"]
scopechanged"openid profile email""openid profile"
Nested objects are compared key by key; lists such as roles are compared whole.

How to use it

  1. Paste the first token into A and the second into B.
  2. Read the list of differences, header first, then payload.
  3. Tick the box to see unchanged claims as well.

What to know

Comparing tokens is the quickest way to see what a configuration change did: a new mapper, a role, a client scope or a different client.

Nested objects such as realm_access and resource_access are compared key by key, so you see exactly which part changed. Lists such as roles are compared whole.

Compare an access token before and after a refresh to see which claims Keycloak issues again and which stay the same.

Why compare two tokens

When something works in one place and not in another, the difference is often in the token. A user who can open a page in staging but not in production, a client that suddenly lost a role, an API that accepts tokens from one app and rejects the other: comparing two tokens side by side shows what changed in seconds.

Reading two long payloads by eye is slow and error-prone, especially with nested role claims. This tool decodes both tokens and lists every field that was added, removed or changed.

How the comparison works

Both tokens are decoded: header and payload, from Base64url to JSON. Then the two JSON objects are walked key by key. Nested objects are compared member by member, so a change deep inside resource_access is reported with its full path. Lists are compared as a whole, so a role list with one extra entry shows as changed, with both versions side by side.

ChangeMeaning
addedThe field exists only in token B
removedThe field exists only in token A
changedThe field exists in both with different values
sameIdentical in both; hidden unless you ask to see it

Time claims are shown both as numbers and as dates, so a changed exp is easy to read. The tool also notes when the two signatures are identical, which only happens when the tokens are identical.

A changed role list in the sample tokens (shortened)
realm_access.roles   changed
  A: ["default-roles-acme", …, "order-manager"]
  B: ["default-roles-acme", …, "order-manager", "billing-viewer"]

How to compare tokens

  1. Paste the first token into Token A.
  2. Paste the second token into Token B.
  3. Read the count of differences, then the header table and the payload table.
  4. Tick “Show unchanged claims too” to see the full picture.

Put the older or working token in A and the newer or failing one in B. Then “added” and “removed” read naturally.

What usually differs

Some differences are expected every time. Others are the clue you are looking for.

Always different

Two tokens issued at different times differ in iat, exp and jti, and usually in the signature. Tokens from different sessions also differ in sid. These differences are normal.

Worth a closer look

  • iss: the tokens come from different realms or hosts.
  • aud: an Audience mapper or client scope changed, or a different client asked.
  • azp: a different client requested the token.
  • realm_access and resource_access: roles were added or removed, or scope rules changed.
  • scope: the client asked for different scopes, or a client scope moved between default and optional.
  • Header kid or alg: the realm rotated keys or changed its signature algorithm.

Use cases with Keycloak

Before and after a configuration change

Get a token, change a mapper, a client scope or a role, get another token, and compare. You see exactly what the change did to the token, and nothing else. The admin console can also generate example tokens: open the client, then Client scopes, then Evaluate, choose a user and generate an access token.

Staging against production

Realm exports drift. Compare a token for the same user and client in both environments to find a missing mapper or a different default scope. For the realm configuration itself, the realm export diff compares whole exports.

Two clients, one user

A user’s token from a web app and from a mobile app can differ because each client has its own scopes, mappers and role scope. Comparing them shows why one app sees a role and the other does not.

Before and after a refresh

Compare the first access token with one obtained by refreshing. Keycloak issues fresh times and id, while auth_time and sid stay the same. If roles changed in between, the refreshed token shows them.

Reading role changes

A role can disappear from a token for reasons that have nothing to do with the user. In Keycloak, a client sees only the roles its scope allows: when Full scope allowed is off on the client’s dedicated scope, only roles in its scope mappings reach the token. A role also needs the roles client scope to be assigned so the mappers that write realm_access and resource_access run.

When the diff shows a role missing, check the user’s role mappings first, then the client’s scope. The token roles viewer lists the roles in a single token clearly.

A worked example: a role that went missing

Suppose users of the web app can no longer create orders, while staff using the admin app still can. Here is how a comparison narrows it down.

  1. Get an access token for the same user from each app, or generate both in the admin console with Client scopes, Evaluate on each client.
  2. Paste the web app’s token into A and the admin app’s into B.
  3. The diff shows azp changed, as expected, and resource_access.orders-api present only in B.
  4. That means the web app’s client is not allowed to see the orders-api roles: its dedicated scope has Full scope allowed off and no scope mapping for them.
  5. Add the scope mapping for the needed role, get a new token, and compare again to confirm.

The whole investigation takes minutes because the token states exactly what the API sees.

Comparing headers

Header differences are rarer, and more telling when they happen.

Header field changedUsual reason
kidThe realm rotated keys, or the tokens come from different realms
algThe realm or client signature algorithm was changed
typDifferent issuers, or a token type setting was changed

If kid differs, check that both keys are in the realm’s key set with the key id matcher. An API that cached the old set will reject tokens with the new kid until it refreshes.

Getting comparable tokens

The best comparisons hold everything constant except the thing you study. Use the same test user, request the same scopes, and get both tokens close together in time. If you compare environments, use the same client id in both. The admin console’s Client scopes, Evaluate tab helps here, because it produces tokens without signing in through an app.

Limits

  • Signatures are not checked. A forged token compares just as easily as a real one; use the signature verifier when it matters.
  • Lists are compared whole. When two long role lists differ, compare the two lines shown to spot the entry.
  • Encrypted tokens (JWE) cannot be compared, because their payload is ciphertext.

Security notes

Both tokens are decoded in your browser and nothing is sent to us. Live tokens still grant access until they expire, so compare tokens from a test realm, or wait until they have expired.

The two sample tokens are made up: token B is token A after a refresh, with a role added and a scope removed. B has a placeholder signature.

Tips for useful comparisons

  • Change one thing at a time between the two tokens.
  • Use the same user and client unless the difference you study is the user or client.
  • Ignore iat, exp, jti and the signature unless timing is the question.
  • Keep a known-good token from a test realm to compare against later.
Questions

Frequently asked questions

Does the tool check the signatures?

No. It compares what the tokens say. Use the signature verifier to check either token.

Why are the two tokens so different in length?

Roles, groups and custom claims add bytes. The table shows which claims differ, and the size calculator shows which claims are largest.

Why does every comparison show `exp`, `iat` and `jti` as changed?

Each token is issued at its own time with its own id, so these always differ. They matter only when you are studying lifetimes.

Why does a role appear in one token and not the other?

Either the user’s roles changed, or the two tokens were requested by clients with different role scopes or client scopes. Compare `azp` first to see whether the same client asked.

Can I compare an access token with an ID token?

Yes, and it is a good way to see which claims Keycloak puts in each. Expect differences in `typ`, `aud` and the role claims.

How do I get example tokens from Keycloak without an app?

In the admin console, open a client, then Client scopes, then Evaluate. Pick a user and generate an example access token or ID token to copy.

Are the tokens sent anywhere?

No. Both are decoded and compared in your browser.

Can I compare a token from Keycloak with one from another provider?

Yes. The comparison works on any two JWTs. Expect many differences in claim names, since each provider shapes its tokens differently.

Why are nested objects compared key by key but lists compared whole?

Object members have names, so each can be matched with its counterpart. List items have only positions, and a role added at the start would make every position look changed, so lists are shown whole instead.

Does the order of claims matter?

No. JSON objects have no order, and the comparison matches claims by name. Two tokens with the same claims in a different order show no differences in the payload.

Rather not run Keycloak yourself?

We run it for you on a cluster of your own, with backups, upgrades and written support. Starter and Premium begin with a 7-day trial.