Skip to content

JWT claims validator

Check a token’s issuer, audience, authorized party, type and times against what your app expects, with clock skew, the way a resource server should.

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

Token and expectations

A sample token issued a minute ago for the made-up realm acme is filled in. It is not signed.

For Keycloak: https://<host>/realms/<realm>, exactly as in the realm’s discovery document.

Your API’s client id or audience. Separate several with commas; any one matching passes.

The client that asked for the token. Leave empty to skip.

Keycloak sets typ to Bearer in access tokens and ID in ID tokens. Leave empty to skip.

Result

This checks the claims only, not the signature. Check the signature with the verifier first.

How to use it

  1. Paste the token.
  2. Enter the issuer, audience and, if you check it, the azp your app expects.
  3. Set the clock skew you allow.
  4. Read each check. Fix the first failure before looking at the rest.

What to know

After the signature, a resource server should check exp and nbf against the clock, iss against the issuer it trusts, and aud against its own name. Any mismatch means the token is not for it.

A Keycloak realm’s issuer is https://<host>/realms/<realm>, and it must match exactly, including the scheme and any path. It is listed in the realm’s discovery document at /.well-known/openid-configuration.

Keycloak sets aud from the clients whose roles the token carries. To add your API to aud, add an Audience mapper to a client scope the client uses. Keycloak also sets a typ claim: Bearer in access tokens and ID in ID tokens.

Why claims need checking

A valid signature proves who issued a token and that it is unchanged. It does not prove the token is meant for you, or that it is still valid. A token for another API, from another realm, or from last week can carry a perfect signature.

That is why RFC 7519 and the OAuth best-practice documents ask resource servers to check claims after the signature: the times, the issuer and the audience at the least. This tool runs those checks the way a careful API would, and explains each result.

The checks, one by one

ClaimRuleFails when
expThe current time must be before itThe token has expired
nbfThe current time must be at or after itThe token is not valid yet
iatShould not be in the futureThe issuer’s clock is ahead, or the token is forged
issMust equal the issuer you trust, exactlyAnother realm, host, scheme or path
audMust contain your API’s identifierThe token was issued for someone else
azpIf you check it, must be the expected clientAnother client obtained the token
typ (claim)If you check it, must be the expected typeAn ID token sent as an access token

All time checks allow a small clock skew in both directions, set in seconds. The default here is 30.

Exact issuer matching

Issuers are compared as strings, character for character. https://auth.example.com/realms/acme and https://auth.example.com/realms/acme/ are different issuers. So are http and https, and a host name and its IP address. The tool points out when only a trailing slash differs.

Audience as a string or a list

RFC 7519 allows aud to be one string or an array. Your check should pass if any entry matches. Enter several expected values separated by commas and the tool passes if any one of them is in the token.

How to validate a token

  1. Paste the token. A sample issued a minute ago is filled in to show how the checks look.
  2. Enter the expected issuer, for Keycloak https://<host>/realms/<realm>.
  3. Enter the expected audience: your API’s client id, or the value your Audience mapper adds.
  4. Optionally enter the expected azp and typ claim.
  5. Set the clock skew you allow, then read the checks from top to bottom.

The checks run against your computer’s clock, updated every second.

How Keycloak fills these claims

Issuer

Keycloak sets iss to the realm’s URL: https://<host>/realms/<realm>. The host part comes from how Keycloak sees the request or from its hostname setting, so a token obtained through an internal address can carry a different issuer than one obtained through the public address. The realm’s discovery document at /realms/<realm>/.well-known/openid-configuration shows the issuer for that address.

Audience

By default Keycloak puts into aud the clients whose client roles appear in the token. Users have roles of the account client by default, so aud often contains account. To add your API, create an Audience mapper in a client scope the calling client uses, and set it to your API’s client id.

Authorized party and type

Keycloak sets azp to the client id that requested the token. It also sets a typ claim: Bearer in access tokens and ID in ID tokens. Checking typ stops a client from sending an ID token where an access token is expected.

Times

Access tokens expire after the Access Token Lifespan, 5 minutes by default, set under Realm settings, Tokens and overridable per client. iat is the issue time; nbf is usually absent.

Use cases

An API returns 401 for valid-looking tokens

Paste a failing token and your API’s configured issuer and audience. The first failed check is usually the answer: a trailing slash in the issuer, a missing audience, or an internal host name in iss.

Writing the validation code

Use the tool as a reference while you configure a JWT library. Every library has settings for issuer, audience and clock skew; they should give the same results as here.

Checking a new client or mapper

After adding an Audience mapper or a new client scope, get a fresh token and confirm the claims changed the way you meant.

Common failures and fixes

ResultUsual fix
Issuer does not match, only a trailing slash differsConfigure the issuer exactly as in the discovery document
Issuer has an internal host nameRequest tokens through the public address, or set Keycloak’s hostname
Audience does not match, token has accountAdd an Audience mapper for your API
Expired, though just issuedCheck the clocks on both machines; sync them with NTP
Token type does not match, token has IDThe client sent its ID token; it should send the access token

The same checks in code

Most JWT libraries do these checks for you once configured. In pseudo-code, the order looks like this.

Validation order for an API trusting the sample realm acme
verify signature with the issuer’s keys, algorithm pinned to RS256
now = current time in seconds
reject if now >= exp + skew
reject if nbf and now < nbf - skew
reject if iss != "https://auth.example.com/realms/acme"
reject if "orders-api" not in aud (string or list)
optionally reject if azp not in allowed clients
optionally reject if typ claim != "Bearer"

The values here are samples. Use your realm’s exact issuer and your API’s audience.

Validating ID tokens in a client app

A client app that receives an ID token checks a slightly different set of claims, defined in OpenID Connect Core.

  • iss must be the provider’s issuer, and aud must contain the client’s own client id.
  • If aud has several values, azp should be present and equal to the client id.
  • exp must be in the future, and iat reasonably recent.
  • If the app sent a nonce in the authorization request, the ID token’s nonce must match it.

Set the expected audience to your client id and the expected typ to ID to run these checks on a Keycloak ID token here.

Checks this tool leaves to you

Some checks depend on your application and cannot be done from the token alone.

  • Scopes: whether scope contains what the endpoint needs, such as orders:write.
  • Roles: whether the caller has the role the action needs; see the token roles viewer.
  • Nonce: whether an ID token’s nonce matches the one your app sent.
  • Replay: whether a jti was seen before, for one-time tokens.

Run the same token through this tool with the values from your API’s configuration. If the tool passes and the API still rejects the token, the problem lies in how the API reads its configuration, not in the token.

Limits of this tool

The tool does not check the signature. Claims in an unverified token prove nothing, because anyone can write them. Verify the signature first with the signature verifier.

It also cannot tell whether a token was revoked or its session ended; that needs a call to the authorization server, such as token introspection.

The sample token on this page is unsigned and made up. Its times follow your clock so the checks have something live to show.

Best practices for resource servers

  • Check the signature, then exp, nbf, iss and aud, on every request.
  • Allow a small clock skew, 30 to 60 seconds, not minutes.
  • Configure one exact issuer per trusted realm.
  • Require your own audience; do not accept tokens meant for other APIs.
  • Reject ID tokens at APIs by checking the token type.
Questions

Frequently asked questions

Why is my token’s audience `account`?

Keycloak adds `account` when the user has roles of the account client, which every user has by default. Add an Audience mapper for your API so its client id is in `aud` too.

How much clock skew should I allow?

Thirty to sixty seconds is common. More than a few minutes hides clock problems that you should fix with NTP instead.

Does this check the signature?

No. Check the signature first with the signature verifier; claims in an unverified token prove nothing.

Why does the issuer differ between environments?

The issuer includes the host name and the realm. Each environment has its own, and a token fetched through an internal address can carry that address. Configure each API with the issuer of the environment it runs in.

What is the difference between `aud` and `azp`?

`aud` names who the token is for, such as your API. `azp` names the client that requested it, such as your web app. An API checks `aud`, and may check `azp` to allow only certain clients.

Should my API accept ID tokens?

No. ID tokens are for the client app to learn who signed in. APIs should accept access tokens only; checking the `typ` claim in Keycloak tokens enforces this.

Is `nbf` required?

No. It is optional in RFC 7519 and Keycloak usually leaves it out. When it is present, a token must not be accepted before that time.

Can a token pass every claim check and still be invalid?

Yes, if its signature is not valid, or if it was revoked. Claims checks complement the signature check and, where needed, introspection; they do not replace them.

How do I check an ID token instead of an access token?

Set the expected audience to your client id and the expected `typ` claim to `ID`. Also compare the token’s `nonce` with the one your app sent, which this tool cannot know.

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.