JWT Token Debugging: A Complete Guide to Decoding and Validating

August 19, 2026 · 10 min read

JSON Web Tokens (JWTs) are the backbone of modern authentication. They carry user identity, permissions, and expiration data in a compact, self-contained format. But when something goes wrong — an unexpected 401, a missing claim, a mysterious expiration error — you need to crack open the token and inspect its contents. That is where a JWT decoder becomes an essential debugging tool.

This guide covers everything you need to know about JWT token debug workflows: the structure of a JWT, how to decode each section, what to look for when things break, and security pitfalls to avoid.

What Is a JWT?

A JWT (pronounced "jot") is a compact, URL-safe token format defined in RFC 7519. It consists of three Base64URL-encoded parts separated by dots:

eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkphbmsiLCJpYXQiOjE2OTAwMDAwMDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
│_________header__________│_________________payload_________________│__________________signature__________________│

Each part serves a distinct purpose:

Part Purpose Contents
Header Token metadata Algorithm (alg) and token type (typ)
Payload Claims (data) User ID, roles, expiration, custom fields
Signature Integrity verification HMAC or RSA signature of header + payload

Decoding the Header

The header is a Base64URL-encoded JSON object. Decoding the first segment:

// Input:  eyJhbGciOiJIUzI1NiJ9
// Decode:
{
  "alg": "HS256",
  "typ": "JWT"
}

The alg field tells the verifier which algorithm was used to sign the token. Common values:

Decoding the Payload

The payload contains the claims — the actual data the token carries. There are three types of claims:

Registered Claims (Standard)

These are predefined in the JWT specification and have specific meanings:

{
  "sub": "1234567890",    // Subject (user ID)
  "name": "Jan Kowalski", // Custom claim
  "iat": 1690000000,      // Issued At (Unix timestamp)
  "exp": 1690003600,      // Expiration (Unix timestamp)
  "iss": "auth.example.com", // Issuer
  "aud": "api.example.com"   // Audience
}
Claim Name Description
iss Issuer Who created the token
sub Subject Who the token is about (usually user ID)
aud Audience Who the token is intended for
exp Expiration When the token expires (Unix timestamp)
nbf Not Before When the token becomes valid
iat Issued At When the token was created
jti JWT ID Unique identifier for the token

Public and Private Claims

Public claims use collision-resistant names (URIs or IANA-registered names). Private claims are custom fields agreed upon between the issuer and consumer — like role, org_id, or permissions.

A JWT decoder reveals the payload in plain text. Never put sensitive data — passwords, credit card numbers, personal details — in a JWT payload. The payload is Base64URL-encoded, not encrypted.

Understanding the Signature

The signature ensures the token has not been tampered with. For HS256, it is computed as:

HMACSHA256(
  base64UrlEncode(header) + "." + base64UrlEncode(payload),
  secret
)

The signature does not encrypt the payload. It only guarantees integrity — confirming that the header and payload were not modified after the token was issued. Without the secret key, an attacker cannot produce a valid signature, but they can read the payload freely.

Common JWT Debugging Scenarios

Token Expired (exp claim)

The most common JWT error. Decode the token and check the exp claim. Convert the Unix timestamp to a human-readable date to see exactly when the token expired. A common mistake is timezone mismatch — the server and client might interpret timestamps differently.

Wrong Audience (aud claim)

If your API rejects a token with "invalid audience," the aud claim does not match what the server expects. Decode the token and compare the aud value against the server's configuration.

Algorithm Mismatch

The header's alg field must match the server's expected algorithm. If the token uses RS256 but the server verifies with an HMAC secret, verification will fail — even if the data is correct.

Malformed Token

A JWT must have exactly three Base64URL segments separated by dots. If a JWT decoder reports "malformed token," check for:

Security Pitfalls to Watch For

The "none" Algorithm Attack

Some JWT libraries accept tokens with "alg": "none" and skip signature verification entirely. An attacker can forge a token with any payload and a null signature. Always whitelist allowed algorithms on the server side — never trust the token's own alg claim.

Algorithm Confusion (RS256 to HS256)

If a server expects RS256 (asymmetric) but the library also accepts HS256 (symmetric), an attacker can sign a token with the server's public key as the HMAC secret. This is a well-documented attack — always enforce the expected algorithm explicitly.

Sensitive Data in Payload

The JWT payload is readable by anyone. It is Base64URL-encoded, not encrypted. Never include passwords, API keys, or personally identifiable information that should remain private.

How to Use the DevKitDock JWT Decoder

Our JWT Decoder makes debugging tokens fast and safe:

  1. Paste your JWT token into the input field
  2. The tool automatically splits the three parts and decodes header and payload
  3. Registered claims like exp, iat, and nbf are displayed as human-readable dates
  4. The signature section is shown separately for inspection
  5. Everything runs client-side — your token is never sent to a server

This is especially useful during development when tokens come from third-party OAuth providers, API gateways, or microservice authentication flows.

Frequently Asked Questions

Is it safe to decode a JWT in an online tool?

Decoding a JWT only reads the Base64URL-encoded payload — it does not reveal the signing secret. Tools that process entirely client-side (like the DevKitDock JWT Decoder) never send your token to a server. However, the payload itself may contain sensitive data, so use caution with tokens containing personal information.

Can I verify a JWT signature with an online decoder?

Signature verification requires the secret key (for HMAC) or public key (for RSA/ECDSA). A web-based decoder can decode the payload without the key, but full verification must happen on your server or in a local script where you have access to the key material.

Why does my JWT say "expired" even though I just received it?

Check for clock skew between your server and the client. The server might be using UTC while your machine is in a different timezone. Also check the exp value — some providers issue tokens with very short lifetimes (5–15 minutes). Decode the token and compare the exp timestamp with the current time.

What is the difference between JWT and OAuth?

JWT is a token format; OAuth is an authorization protocol. OAuth often uses JWTs as its token format (particularly for access tokens and ID tokens), but they are not the same thing. You can have JWTs without OAuth and OAuth without JWTs.

How long should a JWT access token last?

Best practice is short-lived access tokens — 5 to 15 minutes — paired with longer-lived refresh tokens. Short lifetimes limit the damage if a token is compromised. Decode your token's exp claim to verify the actual lifetime.

Comments (0)

Detecting IP...