A JWT decoder can show you what a token contains, but decoding alone does not prove that the token is authentic or safe to use. This guide explains how to inspect JWT structure, validate signatures and registered claims, troubleshoot common authentication failures, and establish a repeatable review process without exposing production credentials.
Overview
JSON Web Tokens (JWTs) are compact strings commonly used to carry authentication or authorization data between an issuer and an API. A typical token has three Base64URL-encoded parts separated by periods:
header.payload.signature
The header describes the JOSE algorithm and token type. The payload contains claims, such as an issuer, subject, audience, or expiration time. The signature is generated from the encoded header and payload, using either a shared secret or an asymmetric private key. These parts are encoded, not encrypted, unless an additional encryption mechanism is used.
That distinction is the foundation of safe JWT debugging. A browser-based JWT decoder can decode the header and payload because those sections are designed to be readable. It cannot establish trust merely by displaying them. A JWT validator must also verify the signature with the correct key and apply the rules expected by the receiving service.
| Check | What it tells you | What it does not prove |
|---|---|---|
| Decode header and payload | What data and algorithm labels are present | That the claims are authentic |
| Verify the signature | That the signed content matches the supplied verification key | That the token is appropriate for every API or user |
| Check expiration and time claims | Whether the token is within its intended time window | That your server clock or business rules are correct |
| Check issuer and audience | Whether the token appears intended for this service | That the user has every permission your application needs |
| Inspect algorithm and key configuration | Whether the token matches the verifier’s expected JOSE setup | That an unfamiliar algorithm should be accepted automatically |
Use a decoder to investigate a test token or understand an API response. Use a trusted server-side library and an explicit validation policy before making an authorization decision. For related API design context, see the REST API authentication methods guide and the OpenAPI specification guide.
What to track
1. The token structure
Start by confirming that the value has the expected three-part shape. Decode each part as Base64URL rather than ordinary Base64, then parse the first two parts as JSON. A valid-looking structure is useful for diagnosis, but malformed JSON, unexpected padding, or an absent signature can indicate truncation, an incorrect environment variable, or a token that is not a signed JWT.
Record the header fields that affect verification, especially alg and kid. The algorithm must be selected by your server’s configured policy, not accepted simply because the token names it. A key identifier can help a verifier select a public key during rotation, but it should not cause the application to fetch arbitrary locations or trust an unapproved key.
2. Registered and application claims
Claims are statements made by the issuer. Common registered claims include:
iss(issuer): identifies the system that issued the token.sub(subject): identifies the principal represented by the token.aud(audience): identifies the intended recipient or service.exp(expiration time): the time after which the token should not be accepted.nbf(not before): the time before which the token should not be accepted.iat(issued at): the time at which the token was issued.jti(JWT ID): an identifier that can support replay tracking or revocation designs.
Track the data type and meaning of each claim. Numeric date claims are generally represented as seconds relative to the Unix epoch, so display them in a readable timezone while preserving the original value for investigation. Application-specific claims, such as roles or scopes, need an agreed schema. A claim named role is not automatically an authorization rule; your API must define which values grant which actions.
3. Verification inputs and failure context
When a token fails validation, record the environment, endpoint, issuer, audience, algorithm, key identifier, and approximate time without copying the complete credential into a ticket or chat message. Also note whether the failure occurs at decoding, signature verification, claim validation, or the later authorization step. This separation prevents a generic “JWT error” from hiding the actual cause.
For payload troubleshooting, you may also use a JSON formatter and validator after removing sensitive values. Do not paste live access tokens, refresh tokens, signing secrets, private keys, or personally identifying claims into an online tool. A local decoder or an isolated development environment is safer for confidential material.
Cadence and checkpoints
JWT debugging is usually event-driven, but a lightweight recurring review helps catch configuration drift. Use this schedule as a practical baseline and adapt it to the risk and change rate of your system.
| Cadence | Checkpoint | Evidence to review |
|---|---|---|
| During every incident | Classify the failure before changing code | HTTP status, verifier error category, issuer, audience, algorithm, key ID, and server time |
| After an authentication change | Test the complete issue-to-API flow | New claims, signing configuration, key selection, clock behavior, and authorization outcomes |
| Monthly or quarterly | Review token assumptions | Accepted algorithms, issuer and audience allowlists, claim types, expiration windows, and logging exposure |
| Before key rotation | Confirm overlap and failure behavior | Key discovery, kid handling, cache refresh, old-token behavior, and rollback steps |
Keep a small set of non-production test tokens representing important states: a valid token, an expired token, a token with the wrong audience, a token with an invalid signature, and a token missing a required claim. Store test material separately from production credentials and document the expected result for each case. This gives teams a repeatable checkpoint when upgrading a JWT library, changing identity-provider settings, or moving between development and staging.
A useful verification policy should be explicit rather than inferred from token contents. In pseudocode, the flow is:
token = readAuthorizationHeader(request)
claims = verifySignature(token, approvedKey, approvedAlgorithm)
requireIssuer(claims, expectedIssuer)
requireAudience(claims, expectedAudience)
requireTimeClaims(claims)
requireScopesForRoute(claims, routePolicy)
The exact function names differ by language and library. The important sequence is to verify the signature before trusting claims, then check issuer, audience, time restrictions, and application permissions. Do not treat a decoded payload as an authorization result.
How to interpret changes
Decoding succeeds, but signature verification fails
This often points to the wrong secret or public key, a changed signing algorithm, a stale key set, a damaged token, or a mismatch between environments. Compare the token’s header with the verifier’s allowlist and confirm that the key belongs to the expected issuer. If the system uses key rotation, inspect how it resolves kid and how it handles a newly published key.
The signature passes, but claims fail
A valid signature means the content was signed by the corresponding key; it does not mean the token is acceptable for your service. An expired exp, future nbf, unexpected iss, or wrong aud should cause rejection according to your policy. Check clock synchronization and the units used for time comparisons before adding tolerance. Any tolerance should be deliberate, limited, and documented rather than used to conceal clock problems.
Authentication passes, but access is denied
This is usually an authorization or application-data issue rather than a decoding issue. Confirm that the route expects the scope or role present in the token, that claim names are mapped consistently, and that the API is evaluating permissions for the correct resource. Compare a known-good test request with the failing request, including the endpoint, tenant or organization identifier, and environment.
Algorithm errors appear after a deployment
Review the configured algorithm on both the issuer and verifier. Never resolve an algorithm mismatch by accepting every algorithm or by disabling signature checks. Shared-secret algorithms require the same secret on both sides; asymmetric algorithms require the issuer’s private key for signing and the corresponding trusted public key for verification. Keep these materials out of browser code and source control.
For a wider API troubleshooting workflow, pair token analysis with structured request inspection and sanitized logs. The Docker Compose troubleshooting guide can help when environment variables or service networking differ between local and deployed environments.
When to revisit
Revisit this JWT guide whenever an authentication flow changes, a signing key is rotated, an identity provider is replaced, a verifier library is upgraded, or an API begins returning unexpected 401 or 403 responses. A quarterly review is a reasonable maintenance checkpoint when no major change is planned. Revisit sooner if logs show repeated signature failures, tokens from an unexpected issuer, missing audiences, unusual expiration behavior, or sensitive token values appearing in diagnostics.
At each review, take these actions:
- Run the non-production token test set and confirm each expected result.
- Verify that accepted algorithms, issuers, audiences, and required claims are explicitly configured.
- Check key rotation,
kidresolution, cache behavior, and rollback documentation. - Search logs, browser storage, analytics tools, and error reports for accidental credential exposure.
- Remove or redact copied tokens from tickets and temporary files; revoke or replace any credential that may have been exposed.
- Update API documentation and integration tests when claim names, scopes, or token lifetimes change.
A JWT decoder is valuable for reading a token during development, but trust comes from a controlled verification process. Keep decoding, signature validation, claim validation, and authorization as separate checkpoints. That habit makes authentication failures easier to diagnose and reduces the risk of treating readable data as verified identity.