JWT Decoder Guide: Inspect Claims, Verify Tokens, and Troubleshoot Authentication Errors
JWTauthenticationOAuthAPIssecurity

JWT Decoder Guide: Inspect Claims, Verify Tokens, and Troubleshoot Authentication Errors

CCircuit Dev Hub
2026-12-01
7 min read

Decode JWT headers and claims safely, verify signatures, and troubleshoot issuer, audience, expiration, clock-skew, and format errors.

A JWT decoder can show you what a token contains, but decoding is not the same as proving that the token is trusted. This guide provides a reusable checklist for inspecting JWT headers and claims, verifying signatures safely, and diagnosing common authentication failures involving expiration, issuer, audience, clock skew, and malformed tokens.

Overview

A JSON Web Token (JWT) is commonly serialized as three Base64URL-encoded sections separated by periods:

header.payload.signature

The header describes the signing method and key reference, the payload contains claims, and the signature protects the encoded header and payload from unauthorized modification. A JWT decoder can parse the first two sections because they are encoded rather than encrypted. Anyone who obtains the token may be able to read those claims.

That distinction matters during debugging. Decoding a JWT tells you what the token says. It does not establish that the issuer created it, that the signature is valid, that the token has not been altered, or that your API should accept it. Treat decoded data as untrusted until your server completes signature and claim validation.

When inspecting a token, avoid sending production credentials to an unfamiliar online developer utility. Use a local decoder, a trusted internal tool, or a redacted sample whenever possible. Access tokens can contain identifiers, scopes, tenant information, or other sensitive operational details even when they do not contain passwords.

JWT claims explained

FieldPurposeWhat to check
algIdentifies the signature algorithm.It must match an explicitly allowed algorithm for this integration.
typOften indicates the token type, such as JWT.Use it as an additional format check where your protocol requires it.
kidIdentifies a signing key.Confirm that the key exists in the issuer's trusted key set.
issIdentifies the token issuer.Compare it with the exact issuer configured for the API.
subIdentifies the subject, often a user or service.Interpret it according to the issuer's contract; do not assume it is an email address.
audIdentifies the intended recipient or API.Check that the expected audience is present and correctly typed.
expExpiration time as a NumericDate.Compare it with the current server time, allowing only documented clock tolerance.
nbfNot-before time as a NumericDate.Reject tokens used before this time unless a controlled tolerance applies.
iatTime at which the token was issued.Use it for diagnostics or age policies, not as proof of validity.
jtiA token identifier when supplied.Use it for tracing or replay controls only when your system supports them.

Checklist by scenario

Scenario 1: You need to decode a JWT token

  1. Confirm that the value has exactly three dot-separated segments.
  2. Decode the header and payload as Base64URL, not ordinary form-encoded Base64.
  3. Parse each decoded section as JSON.
  4. Record the values of alg, kid, iss, aud, exp, and nbf.
  5. Do not treat readable claims as evidence that the token is authentic.

For a quick local inspection on a Unix-like system, this command decodes the first two sections. It is a diagnostic example, not a verification step:

python3 - <<'PY'
import base64, json, sys

token = sys.stdin.read().strip()
parts = token.split('.')
if len(parts) != 3:
    raise SystemExit('Expected three JWT segments')
for name, value in [('header', parts[0]), ('payload', parts[1])]:
    padded = value + '=' * (-len(value) % 4)
    data = base64.urlsafe_b64decode(padded)
    print(name + ':')
    print(json.dumps(json.loads(data), indent=2))
PY

Paste a test token into standard input rather than placing a live credential in shell history. For a browser or Node.js utility, a simple parser can expose the same distinction:

function decodeJwtPart(part) {
  const base64 = part.replace(/-/g, "+").replace(/_/g, "/");
  const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
  const bytes = Uint8Array.from(atob(padded), character => character.charCodeAt(0));
  return JSON.parse(new TextDecoder().decode(bytes));
}

function inspectJwt(token) {
  const parts = token.split(".");
  if (parts.length !== 3) throw new Error("Malformed JWT");
  return {
    header: decodeJwtPart(parts[0]),
    payload: decodeJwtPart(parts[1]),
    signature: parts[2]
  };
}

This code parses content only. It does not verify the signature and should not be used as an authorization decision.

Scenario 2: An API returns an authentication error

  1. Confirm the request sends the intended token in the expected authorization header, commonly Authorization: Bearer <token>.
  2. Check whether a proxy, gateway, cookie policy, or client interceptor removed or replaced the token.
  3. Decode the token locally and compare iss, aud, exp, and nbf with the API configuration.
  4. Verify the signature with the issuer's trusted public key or key set.
  5. Compare server clocks and inspect the API's precise validation error in controlled logs.
  6. Retry with a newly issued test token only after identifying whether the failure is client-side, configuration-related, or server-side.

Scenario 3: You are implementing JWT verification

Use a maintained JWT library rather than writing cryptographic verification from scratch. Configure an explicit algorithm allowlist, trusted issuer, expected audience, key source, and permitted clock tolerance. The verifier should select keys through a trusted configuration or issuer-controlled key-discovery process, then validate the signature before application code relies on claims.

Your verification checklist should include:

  • Rejecting malformed tokens and tokens with an unexpected segment count.
  • Allowing only the algorithms your application actually supports.
  • Checking the signature against the correct key and algorithm.
  • Validating issuer and audience using exact, documented values.
  • Checking expiration and not-before claims when required by the token contract.
  • Applying a small, intentional clock-skew tolerance rather than disabling time checks.
  • Authorizing the requested action from validated scopes or roles, not from arbitrary client-supplied fields.

What to double-check

Algorithm and key selection

The alg value is input from the token and must not by itself determine what the server accepts. Configure the permitted algorithm in application settings and reject unexpected values. If the header contains kid, make sure key lookup is constrained to the trusted issuer and cannot be redirected to an attacker-controlled location. A successful parse is not a successful signature check.

Issuer and audience

An issuer identifies who created the token; an audience identifies the service for which it was issued. A token can have a valid signature and still be wrong for your API. This commonly happens when a frontend token is sent to a backend that expects a different audience, or when development and production identity-provider configurations are mixed.

Expiration, not-before, and clock skew

JWT time claims are generally represented as seconds since the Unix epoch. Check the server's UTC time, not only the developer workstation's clock. An expired token produces a different investigation path from a token that is not yet valid. If your system allows clock tolerance, keep it explicit, small, and consistent across services.

Malformed encoding

Look for copied quotation marks, whitespace, line breaks, URL decoding, truncated headers, and tokens passed with the word Bearer included in the value expected by a library. Base64URL padding may be omitted in a JWT, so a decoder may need to restore padding before parsing. A JSON parser error usually points to corrupted or incorrectly decoded input rather than an authorization-policy failure.

Common mistakes

  • Using a decoder as a verifier: readable claims are not proof of origin or integrity.
  • Trusting client-side claims: authorization must be enforced by the server after verification.
  • Accepting every algorithm: an algorithm supplied by an untrusted token should not silently change verification policy.
  • Skipping audience validation: a token intended for one service may be validly signed but inappropriate for another.
  • Logging complete tokens: logs, error reports, browser storage, and screenshots can expose bearer credentials. Log a request identifier and selected non-sensitive diagnostics instead.
  • Assuming every JWT is encrypted: standard signed JWT payloads are usually readable by anyone holding the token. Do not put secrets in ordinary claims.
  • Refreshing without diagnosis: repeatedly requesting new tokens can hide a bad issuer, audience, key, or clock configuration.

When to revisit

Return to this checklist whenever an identity provider, API gateway, JWT library, runtime, key-rotation process, or browser storage strategy changes. Recheck the integration when moving between development, staging, and production, when a new audience or scope is introduced, or when an API begins returning unauthorized responses after an otherwise unrelated deployment.

For a practical incident workflow, save the request timestamp, environment, endpoint, HTTP status, token segment count, non-sensitive claim summary, configured issuer and audience, selected algorithm, key identifier, and server clock status. Never include the full bearer token in a ticket. Compare a known-good and failing request, then work through the order below:

  1. Is the token present and unmodified in the request?
  2. Can its header and payload be decoded as valid JSON?
  3. Is the algorithm permitted and is the signing key trusted?
  4. Do issuer and audience exactly match the API's expectations?
  5. Are expiration and not-before times valid on the verifying server?
  6. Does the verified subject have the required scope or role?

That sequence separates formatting problems from cryptographic failures and authorization-policy failures. It also keeps a JWT decoder in its proper role: a useful inspection tool within a broader verification and troubleshooting process, not a substitute for authentication.

Related Topics

#JWT#authentication#OAuth#APIs#security
C

Circuit Dev Hub

Developer Tools Editor

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.