A JWT decoder can quickly reveal why an API request is being rejected, but decoding is only inspection—not proof that a token is authentic. This guide explains how to decode a JWT safely, read its claims, validate its signature and context, and build a repeatable troubleshooting workflow for login failures, key rotation, clock differences, and authorization errors.
Overview
JSON Web Tokens (JWTs) are compact strings commonly used to carry claims between an identity provider, an application, and an API. A typical token has three dot-separated parts:
- Header: Describes token metadata, such as the signing algorithm and key identifier.
- Payload: Contains claims, such as the subject, issuer, audience, and expiration time.
- Signature: Allows a verifier to check whether the signed content has been altered and whether it was signed by a trusted key.
A JWT decoder reads the header and payload by reversing their URL-safe Base64 representation. It does not, by itself, validate the signature, confirm the issuer, or prove that the token was issued for your application. Treat decoded values as untrusted input until your application has completed all required checks.
For a quick inspection, use a local command-line utility or a browser-based decoder only with a deliberately non-sensitive token. Access tokens, refresh tokens, session tokens, and tokens copied from production logs should not be pasted into an online developer tool unless your security policy explicitly permits it. Even when the payload is readable, it may contain identifiers, scopes, email addresses, or other private data.
What to track
JWT structure and claims
Start by recording the token’s structure without sharing the complete token. A redacted example might preserve the header and selected claim names while removing values. The following claims deserve particular attention:
| Claim | What it usually indicates | What to check |
|---|---|---|
iss | The issuer that created the token | It matches the issuer configured for the service and environment. |
sub | The token subject or user identifier | Your application interprets the identifier consistently and does not confuse it with an email address. |
aud | The intended recipient or audience | The value matches the API or service performing validation. |
exp | Expiration time as a NumericDate | The current server time is before expiration, allowing for an explicitly defined clock-skew tolerance. |
nbf | Not-before time | The token is not being used before the permitted start time. |
iat | Time the token was issued | The value is plausible and useful for diagnosing stale or unexpectedly reused tokens. |
jti | A token identifier, when supplied | Your design handles replay or revocation requirements appropriately. |
scope or roles | Permissions associated with the token | The API maps them to the expected authorization rules. |
Claim names and meanings can vary by identity provider. The presence of a claim does not automatically make it trustworthy; trust comes from successful signature validation and an approved issuer, algorithm, audience, and key.
Header values and key selection
Inspect alg and, where present, kid. The algorithm must be selected by server-side configuration rather than accepted blindly from the token header. The key identifier can help a verifier choose the correct public key during rotation, but it must not be treated as authorization. A token that names a familiar key identifier still requires a valid signature and all claim checks.
A safe inspection workflow
- Copy a token from a controlled test environment, or create a test token with no sensitive claims.
- Split it at the two periods and confirm that it has three segments.
- Decode the header and payload with a trusted local tool or library.
- Check whether timestamps are represented as seconds since the Unix epoch and compare them with the validating server’s clock.
- Record the issuer, audience, algorithm, key identifier, expiration, and relevant scopes without storing the raw token in a ticket or chat transcript.
- Validate the signature using the identity provider’s trusted key set or an explicitly configured verification key.
- Test the same token against the actual API, because gateway configuration and application authorization may apply additional rules.
For local debugging, a JWT library in your application language is preferable to manually implementing cryptography. A decoder is useful for visibility; a maintained JOSE-compatible library is the safer basis for signature and claim validation.
Cadence and checkpoints
JWT troubleshooting is not a one-time task. Add token validation checks to the normal maintenance cycle for each service that accepts JWTs.
At each release or configuration change
- Confirm the accepted issuer, audience, algorithms, and signing keys.
- Verify that test tokens cover expired, not-yet-valid, wrong-audience, wrong-issuer, and insufficient-scope cases.
- Check that validation failures return an appropriate authentication or authorization response without exposing token contents.
- Review logs to ensure they contain useful error categories but not raw access or refresh tokens.
Monthly or quarterly
Review identity-provider configuration, key-set retrieval, cache behavior, clock synchronization, token lifetimes, and library versions. The exact interval should follow your risk model and change-management process. A recurring review is especially useful for services with multiple environments, gateways, mobile clients, or independently deployed APIs.
During key rotation
Check that validators can recognize the new key while still handling tokens signed with the old key during the planned overlap period. Confirm that a failed key-set request does not silently cause the service to accept an unknown key or skip signature validation. Test both newly issued and previously issued tokens according to the issuer’s rotation procedure.
How to interpret changes
Different decoded values point to different classes of failure. An exp error usually suggests an expired token, a stale client, or clock disagreement. Compare the token’s expiration with the validator’s time and inspect whether the client is reusing a cached token. Avoid solving widespread clock problems by adding an unnecessarily large tolerance; investigate time synchronization first.
A wrong aud value often means that a token issued for one API is being sent to another, or that a client and resource server use different environment configuration. An iss mismatch can indicate a development token reaching production, a changed identity-provider domain, or an issuer URL normalization problem. Check the complete configured value rather than relying on a similar-looking hostname.
A signature failure commonly results from an incorrect key set, an unavailable key endpoint, a stale key cache, a mismatched algorithm, or a modified token. Do not respond by accepting more algorithms or skipping verification. Instead, compare the token header’s kid with the trusted key set, confirm that the validator is using the intended issuer, and inspect key-rotation timing.
If signature validation succeeds but access is denied, the problem may be authorization rather than authentication. Compare the token’s scopes or roles with the API’s policy, and verify that the application is reading the expected claim format. A valid identity token is not necessarily a valid API access token, and a valid access token does not guarantee permission for every endpoint.
For OAuth-based systems, keep the roles of the authorization server, client, and resource server distinct. The token endpoint may issue a token successfully while the resource server rejects it because its audience, issuer, scope, or signing key does not match local expectations.
When to revisit
Revisit this JWT decoder guide whenever a login or API authorization flow changes, an identity provider is added, signing keys are rotated, a validation library is upgraded, or a service moves between environments. It is also worth reviewing after an incident, a new gateway deployment, a change to token lifetimes, or a decision to add revocation and replay protections.
Use this practical checklist during the next authentication investigation:
- Redact the token and inspect its three-part structure locally.
- Write down
iss,aud,exp,nbf,alg,kid, and permission claims. - Compare the values with the validator’s environment-specific configuration.
- Check server clocks and key-set availability.
- Validate the signature with a maintained library and trusted keys.
- Test authorization separately from authentication.
- Remove raw tokens from temporary notes, logs, screenshots, and support tickets.
For related encoding and debugging workflows, see the Base64, URL Encoding, and Hashing guide and the URL Encoding for APIs guide. If your service is deployed in containers, the Dockerfile best practices guide can help keep the runtime and configuration workflow consistent.