A JWT decoder can reveal why an API request is failing, but decoding is not the same as proving a token is trustworthy. This checklist explains how to inspect a token safely, read its claims, troubleshoot validation errors, and separate development diagnostics from security decisions.
Overview
A JSON Web Token (JWT) is typically a compact string with three dot-separated parts: a header, a payload, and a signature. The first two parts are encoded JSON objects. The signature is the result of signing the encoded header and payload with a cryptographic key. A JWT decoder can usually display the header and payload without having access to the signing key.
That convenience has an important limitation: decoding only tells you what the token contains. It does not confirm that the token was issued by the expected authority, that its contents are unchanged, or that it is valid for your application. Treat decoded claims as diagnostic data until verification and application-specific checks have completed.
For safe troubleshooting, use this sequence:
- Confirm that the value is the expected token, not an entire
Authorizationheader or a different credential format. - Separate the three JWT segments at the periods.
- Decode the header and payload locally or with a tool approved for the token's environment.
- Inspect claims such as
iss,sub,aud,exp,nbf, andiat. - Verify the signature with the expected algorithm, key, and issuer configuration.
- Compare the token's claims with the API's authorization requirements and the server's current clock.
A token may contain personal, operational, or authorization-related information even though its payload is not encrypted. Do not paste production tokens into an unfamiliar online JWT decoder. Prefer a local decoder, a controlled internal utility, or a redacted test token. If a live credential has been exposed, follow your organization's revocation and rotation procedure rather than treating decoding as harmless inspection.
Checklist by scenario
When a token will not decode
- Copy only the token value. Remove the
Bearerprefix if the tool expects the JWT itself. - Check that the value has exactly two periods and therefore three segments.
- Look for line breaks, quotation marks, trailing punctuation, URL encoding, or whitespace added by a log or environment variable.
- Confirm that the credential is actually a JWT. Opaque access tokens and other token formats cannot be interpreted as JWTs merely because they are used in an authorization header.
- Decode the header and payload separately if your diagnostic workflow supports it. A malformed segment often identifies whether the problem is structure or content.
When an API returns an expired-token error
- Read
expas a numeric date and compare it with the server's current time, not only the time on your laptop. - Check
nbf, which can prevent acceptance before a specified time. - Inspect
iatto determine whether the token was issued at an unexpected time. - Check for clock skew between the identity provider, API server, gateway, container, or virtual machine.
- Verify that refresh logic is not reusing a cached token after its usable lifetime.
When the audience or issuer is rejected
- Compare
isswith the exact issuer configured by the API, including scheme, host, path, and relevant trailing-slash conventions. - Compare
audwith the API's expected audience. Depending on the implementation, the audience may be a string or an array of strings. - Make sure a token issued for one environment or service is not being sent to another.
- Check whether the client requested a token for the intended resource or scope rather than merely obtaining a token successfully.
When signature verification fails
- Confirm that the verifier allows the algorithm shown in the header and that the algorithm is configured explicitly rather than inferred from untrusted input.
- For asymmetric signing, confirm that the verifier has the correct public key and can resolve the token's key identifier, often represented by
kid. - Check key rotation and key-set caching. A verifier may temporarily hold an old key or fail to retrieve a newly published one.
- Ensure the token was not altered by a proxy, copied with a missing character, or reconstructed by changing its decoded JSON.
- Distinguish a bad signature from a missing key, unavailable key endpoint, unsupported algorithm, or malformed token. These failures require different fixes.
When authorization fails after verification
- Check the claims your application actually uses for roles, permissions, scopes, groups, or tenant identity.
- Confirm the required scope format and whether the API expects a space-delimited string, an array, or a provider-specific claim.
- Check route-level policy and resource ownership separately from token validity. A valid token can still lack permission for a particular operation.
- Review the request method, path, tenant header, and service identity alongside the token. Authorization decisions rarely depend on the token alone.
| Claim | Typical meaning | What to check |
|---|---|---|
iss | Issuer | Does it match the configured identity provider exactly? |
sub | Subject or principal | Does it identify the expected user, service, or client? |
aud | Intended audience | Is this token meant for this API or resource? |
exp | Expiration time | Has the server's current time passed it? |
nbf | Not-before time | Is the token being used too early? |
iat | Issued-at time | Was it created when expected? |
jti | Token identifier | Is replay detection or revocation keyed to this value? |
scope, roles, or provider-specific claims | Permission information | Does the application map these claims to the required policy? |
What to double-check
Decoding and validation answer different questions. Decoding asks, “What bytes and JSON values are present?” Signature verification asks, “Was this content signed by a trusted key, and has it remained unchanged?” Application validation asks, “Is this token acceptable for this request right now?” A secure implementation performs all relevant checks rather than accepting a token because its payload looks reasonable.
Before using a JWT decoder or validator, run this environment-safety checklist:
- Token sensitivity: Use a fabricated, expired, or redacted token whenever possible. Remember that removing the signature does not necessarily remove sensitive payload data.
- Tool trust: Confirm whether an online tool sends input to a server. For production diagnostics, choose a local or approved internal utility.
- Logging: Search application, gateway, browser, CI, and observability logs for accidental bearer-token capture. Mask authorization headers and token-like values.
- Algorithm policy: Configure accepted algorithms and key sources on the verifier. Do not let the token header decide which security method the server will use.
- Key selection: Validate the issuer and select keys from a trusted configuration or trusted issuer metadata. A
kidvalue alone is not proof that a key is safe. - Time handling: Use a reliable server clock and document any narrowly scoped clock-skew tolerance. A broad tolerance can hide deployment or synchronization problems.
- Claim types: Treat claims as typed values. In particular, validate numeric dates as numeric dates and handle audience values according to the verifier's expected string or array form.
For a reproducible API investigation, capture the request URL, method, response status, response body, server environment, token issuance time, and relevant verifier logs without recording the credential itself. A request-debugging workflow such as the REST API curl guide can help separate transport errors from authentication and authorization errors.
Common mistakes
- Calling a decoder a validator: A readable payload is not evidence of authenticity.
- Assuming JWTs are encrypted: Standard signed JWT payloads are encoded, not automatically confidential. Use an encryption design when confidentiality is required.
- Trusting client-side checks: Browser code may decode a token for display, but the API must perform authoritative verification and authorization.
- Ignoring the issuer and audience: A correctly signed token can still be intended for a different service or environment.
- Changing the payload during testing: Any change to signed content should cause verification to fail. If it does not, investigate the verifier configuration immediately.
- Blaming expiration for every failure: A 401 response may result from a malformed header, wrong key, issuer mismatch, audience mismatch, unavailable key set, or policy failure.
- Publishing copied tokens in issue trackers: Redact the token and use a sanitized claim sample. A token shared for debugging may remain usable until it expires or is revoked.
When to revisit
Revisit this JWT troubleshooting checklist whenever authentication libraries, identity-provider settings, key-rotation procedures, API gateways, or deployment environments change. It is especially useful before moving a service from development to staging or production, after changing an audience or scope, and during an incident involving unexpected 401 or 403 responses.
Make the review practical by maintaining a small, non-sensitive test set: a valid token for each supported audience, an expired token, a not-yet-valid token, a token with insufficient scope, a token signed with an unapproved key, and a malformed token. Run these cases against every verifier or gateway change and record the expected status without storing real credentials.
When an error appears, start with the smallest safe reproduction, compare clocks, inspect claims, verify issuer and audience, then review key and algorithm configuration. If the token may have been exposed, stop sharing it, remove it from logs and tickets where possible, and follow the relevant rotation or revocation process. This approach keeps a JWT decoder useful as a diagnostic aid without confusing inspection with trust.