A JWT decoder can reveal a token’s structure in seconds, but decoding alone does not prove that a token is authentic or usable. This guide provides a reusable JWT debugging workflow for checking claims, expiration, algorithms, signing keys, browser privacy, and API behavior without exposing production credentials.
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 Base64URL-encoded parts separated by periods: a header, a payload, and a signature. The header describes the token type and signing algorithm; the payload contains claims such as the issuer, subject, audience, and expiration; and the signature is used to verify integrity.
That structure creates an important distinction: decoding is not validation. A browser-based JWT decoder can usually display the header and payload without a key. Validation requires checking the signature against the expected key, confirming that the algorithm is allowed, and evaluating time- and application-specific claims. Treat a decoded token as inspectable data, not as trusted evidence.
Use the least sensitive token possible while debugging. A token from a local development environment or a deliberately created test account is preferable. Never paste a production access token, refresh token, private key, client secret, or unredacted authorization header into an online tool unless your organization has explicitly approved that workflow.
| Tool type | Best use | Validation capability | Privacy and export checks |
|---|---|---|---|
| Browser-based JWT decoder | Quickly inspect header and claims | Often limited unless you provide an appropriate verification key | Confirm whether processing occurs locally or data is sent to a server; avoid automatic history or sharing features |
| Local CLI or desktop utility | Repeatable inspection in a controlled environment | Can support signature checks when configured with the correct key and algorithm | Review shell history, temporary files, logs, and copied output |
| Application library or test harness | Reproduce the exact API verification path | Best option for testing issuer, audience, time claims, key selection, and policy rules together | Keep test keys and fixtures separate from production secrets; control exported logs |
| API debugging tool | Compare token behavior across requests and environments | Usually delegates validation to the target API rather than validating independently | Check saved collections, request history, team workspaces, and shared variables |
Checklist by scenario
When a token appears malformed
- Copy only a redacted or test token and preserve the three-part structure.
- Check that the value contains two periods and that no quotation marks, line breaks, or
Bearerprefix were included in the token field. - Decode the header and payload separately. Base64URL encoding is not the same as ordinary Base64, so use a JWT-aware decoder.
- Confirm that the payload is valid JSON and that the token was not truncated by a proxy, cookie limit, log formatter, or environment variable.
- Compare the token issued by the identity provider with the token actually sent by the client.
When the API returns an expired-token error
- Read the
expclaim and compare it with the API server’s current time, not only your workstation’s clock. - Check
iatandnbfas well. A token can be rejected because it is not yet valid even when its expiration is in the future. - Verify whether the application uses seconds since the Unix epoch, as is customary for registered JWT time claims.
- Look for clock drift between the client, identity provider, gateway, and API.
- Confirm that a refresh flow is not accidentally sending the old access token after obtaining a replacement.
When signature validation fails
- Record the expected issuer, audience, algorithm, key identifier, and key source for the environment under test.
- Compare the token header’s
algandkidvalues with the verifier’s allowed configuration. - Make sure the verifier is using the correct public key, shared secret, or key-set endpoint for that issuer and environment.
- Check whether a signing-key rotation occurred and whether the verifier can select a new key while still handling tokens signed by the previous active key.
- Reproduce the failure through the application’s own validation library or middleware. A standalone validator may not apply the same policy as the API.
When changing identity providers or environments
Create a comparison record for a working token and a failing token using only non-sensitive fixtures. Compare iss, aud, sub, scopes, roles, kid, algorithm, and time claims. Then verify that the API configuration points to the intended issuer and key set. A token can be correctly signed yet rejected because it was issued for a different audience or tenant.
What to double-check
Use this short review before concluding that an authentication problem is a token problem:
- Header: Confirm the token type, permitted
alg, and optionalkid. Do not let an untrusted token choose an algorithm outside the verifier’s explicit allowlist. - Issuer: Match
issexactly against the configured identity provider. Differences in scheme, host, path, or trailing slash may matter. - Audience: Check that
audidentifies the API being called, rather than a frontend, login client, or another service. - Time: Inspect
exp,nbf, andiat, then account for controlled clock tolerance only where the application deliberately supports it. - Signature: Decode the token first if useful, but trust claims only after signature verification succeeds with the expected key.
- Authorization: Authentication proves identity or token validity; it does not automatically grant permission. Check scopes, roles, tenant identifiers, and resource-level access separately.
- Transport: Ensure the client sends exactly one authorization scheme and that a gateway is not stripping, rewriting, or replacing the header.
- Observability: Log safe identifiers such as a request ID, issuer, key ID, and failure category. Avoid logging complete tokens or secrets.
For a broader request-level investigation, pair this workflow with an API debugging tool that lets you compare headers, status codes, redirects, and response bodies across environments. An OpenAPI validator can also help identify mismatches between documented security requirements and the API’s expected behavior.
Common mistakes
- Confusing encoding with encryption: JWT header and payload data is normally readable by anyone who has the token. Do not put confidential information in claims unless an appropriate encryption design is in place.
- Assuming a valid shape means a valid token: Three correctly formatted segments do not establish authenticity, freshness, or authorization.
- Testing with the wrong key set: Development, staging, and production commonly use different issuers or signing keys. A key that verifies one environment may be wrong for another.
- Trusting the displayed algorithm: The algorithm named in a token is input from an untrusted source. The verifier must enforce its own approved algorithm policy.
- Copying secrets into shared tools: Browser history, saved workspaces, shell history, screenshots, browser extensions, and CI logs can retain sensitive values.
- Ignoring the full request: A valid token can still produce a
401because of transport or issuer problems, or a403because the caller lacks permission. - Removing all time tolerance: Excessive tolerance weakens expiry checks, but zero tolerance can create avoidable failures in distributed systems. Apply a documented, minimal policy.
When to revisit
Revisit this JWT decoder and validator checklist whenever an identity provider changes, signing keys rotate, an API gateway is replaced, or authentication behavior differs between local, staging, and production environments. It is also worth reviewing before a major release, before seasonal planning or traffic cycles, and whenever a developer utility changes how it stores, processes, or exports pasted data.
Keep a small, version-controlled set of synthetic test tokens for expected cases: valid, expired, not-yet-valid, wrong-audience, wrong-issuer, insufficient-scope, and unknown-key scenarios. Store no production secrets in those fixtures. During each review, confirm the approved algorithms, key-discovery configuration, claim requirements, log-redaction rules, and browser-tool policy.
When an authentication failure occurs, finish with three artifacts: a redacted token comparison, the exact request and response context, and the verifier configuration used by the failing service. That record turns a one-off decode into a repeatable API authentication debugging workflow and makes future key rotations or provider changes easier to diagnose.