JWTs are convenient for moving authentication data between services, but a decoded token is not automatically a trusted token. This guide presents a repeatable workflow for inspecting JWT structure, reviewing claims, validating signatures and timestamps, and debugging failures without exposing sensitive credentials to third-party tools.
Overview
A JSON Web Token, or JWT, is commonly used to carry claims between an identity provider, an application, and an API. A typical signed JWT contains three URL-safe Base64-encoded parts separated by periods:
header.payload.signature
The header describes the token type and signing algorithm. The payload contains claims such as a subject, issuer, audience, expiration time, or scope. The signature helps a recipient verify that the header and payload were signed with an expected key.
Decoding and validating are different operations. A JWT decoder can usually display the header and payload without possessing a key. That is useful for debugging, but it does not prove that the token was issued by a trusted system or that its claims should be accepted. Validation requires checking the signature and applying the receiving service's rules for issuer, audience, time limits, and permissions.
Also remember that a signed JWT is generally not encrypted. Anyone who receives the token may be able to decode its readable sections. Treat access tokens, refresh tokens, and copied authorization headers as sensitive credentials, even when you are only investigating a formatting problem.
Step-by-step workflow
1. Capture the right token and context
Start by recording where the token came from and which request failed. Note the API route, HTTP status, environment, client or service involved, and approximate time. This context often distinguishes an expired token from an audience mismatch or a configuration problem.
When possible, work with a redacted copy or a token created specifically for development. Do not paste production tokens into a public JWT decoder, browser extension, chat system, issue tracker, or shared document. If a real credential was exposed, follow your organization's process for revoking or rotating it.
2. Check the token shape
Count the period-separated segments before using a tool. A conventional signed JWT has three segments. A token with two segments may be an encrypted JWT, while a value with a different structure may be an opaque session token or a malformed authorization value. The number of segments alone does not establish whether the token is safe or valid.
Check for common transport mistakes: an omitted Bearer prefix, extra quotation marks, line breaks inserted during copying, URL encoding applied twice, or a truncated value. Keep the original token separate from any cleaned copy so you can compare them.
3. Decode the header and payload
Use a local library, a trusted development utility, or an offline decoder to inspect the first two segments. Base64url encoding is not the same as ordinary text encoding, so a proper decoder is preferable to manually replacing characters. If you need to inspect a JSON result, a JSON formatter can help validate and indent a redacted header or payload.
Review the header first. The alg value identifies the declared signing algorithm, and kid may identify which key a verifier should select. Treat both as input, not as instructions to blindly trust. The server should allow only algorithms and key sources configured for that application.
4. Review claims as data
Inspect the payload for claims that matter to the receiving service:
issidentifies the expected issuer.audidentifies the intended audience, which may be a string or an array.subidentifies the subject, often a user or service.expsets an expiration time as a numeric date.nbfprevents acceptance before a specified time.iatrecords the time the token was issued.jtican identify a particular token when replay tracking is used.scope,roles, or similar claims may influence authorization.
A claim's presence does not make it trustworthy. The application must validate the signature before relying on claims, then apply its own authorization rules. A valid token for one audience should not automatically authorize access to every API.
5. Validate the signature and algorithm
Signature validation should happen in the service that accepts the token, using a configured secret or a trusted public key. For asymmetric signing, the verifier commonly obtains a public key associated with the issuer and the token's key identifier. For symmetric signing, the secret must remain available only to authorized services.
Do not choose verification behavior solely from the token's header. Configure an algorithm allowlist, verify that the selected key is appropriate for that algorithm, and reject unexpected algorithm changes. A decoder that displays a green or successful result may only have parsed the token; confirm what the tool actually verifies before treating its output as a security check.
6. Validate time, issuer, audience, and permissions
After the signature passes, validate the claims required by the API. Compare exp and nbf against a reliable clock, allowing only a small, deliberate clock-skew window if the system needs one. Check that iss matches the configured issuer and that aud includes the current service. Then apply authorization rules to the subject, scopes, roles, tenant, or resource being requested.
Keep authentication and authorization separate in logs and code. A token can be authentic but still lack permission for a particular operation.
Tools and handoffs
A safe workflow uses different tools for different questions:
- JWT decoder: inspect the structure, header, and readable claims. Use redacted or development tokens whenever possible.
- Application or language library: perform signature and claim validation in the same environment that protects the API.
- API client: reproduce the request with a controlled token, then compare response status, headers, and server-side logs.
- JSON formatter: make decoded data easier to review, while avoiding accidental uploads of secrets.
- Key and issuer configuration: confirm the expected issuer, audience, algorithm, key identifier, and key rotation behavior.
The online developer tools toolkit provides a broader set of utilities for API and data debugging, while the guide to API testing tools can help structure repeatable request checks. These tools support investigation; they should not replace the application's verification path.
For team handoffs, record the token's non-sensitive metadata, the failing endpoint, the observed claim values, the configured expectations, and the exact validation error. Avoid sharing the complete token when a header, redacted payload, or token fingerprint is enough.
Quality checks
Before closing a JWT debugging task, run through this checklist:
- Was the token copied without a prefix, quotation mark, truncation, or unexpected whitespace?
- Does its structure match the token type the application expects?
- Was the header and payload decoded only for inspection, not mistaken for validation?
- Is the declared algorithm permitted by server configuration?
- Was the signature checked with the correct secret or trusted public key?
- Do issuer and audience match the receiving service?
- Are expiration and not-before times valid relative to the server clock?
- Does the subject have the required scope, role, tenant, or resource permission?
- Were sensitive tokens kept out of external tools, logs, screenshots, and tickets?
- Can the failure be reproduced with a newly issued development token?
Common symptoms can narrow the investigation. A malformed-token response points toward transport or parsing problems. A signature error suggests the wrong key, algorithm, issuer configuration, or a modified token. An expiration error suggests token lifetime or clock issues. A successful authentication followed by a forbidden response usually indicates an authorization mismatch rather than a decoding problem.
When to revisit
Revisit this workflow whenever the identity provider, API gateway, authentication library, key-distribution method, or token claims change. It also deserves a fresh review when an application adds a new audience, changes scopes or roles, introduces a new environment, or begins rotating signing keys.
Keep a small, non-sensitive test matrix for each protected service: a valid token, an expired token, a token with the wrong audience, a token signed with an untrusted key, and a token lacking the required permission. Run those cases after authentication changes and document the expected result. If the platform or verification library changes, confirm that algorithm allowlists, claim handling, clock-skew rules, and key lookup behavior still match the application's design.
The practical habit is simple: decode to understand, validate in the application, authorize against the requested resource, and protect every token throughout the debugging process. That separation makes JWT issues easier to diagnose without turning a developer utility into an unintended security risk.