100% Free & Client-Side: All 92 tools run locally inside your browser — zero server uploads, zero signups.
Developer Tools9 min readUpdated 2026-04-13

JWT Tokens Explained: How to Safely Decode and Debug JSON Web Tokens

Master RFC 7519 JSON Web Token architecture. Understand the three dot-separated Base64URL segments, standard claims (`exp`, `iat`, `sub`), and critical security pitfalls.

Sophia Lindqvist

Principal Application Security Engineer

What Is a JSON Web Token (JWT) and Why Stateless Auth Uses It

Standardized under IETF RFC 7519, a **JSON Web Token (JWT, pronounced 'jot')** is a compact, URL-safe cryptographic token format used to pass verified identity and permission claims between an authentication server and client applications. Whenever you sign in with OAuth 2.0 or OpenID Connect (OIDC)—via Auth0, Clerk, Firebase Auth, AWS Cognito, Supabase, or NextAuth—your browser receives a signed JWT access token.

Before JWTs, web applications relied almost exclusively on stateful **Server Sessions**: when a user logged in, the server created a row in a Redis or SQL `sessions` table and sent an opaque `session_id` cookie to the browser. On every subsequent API request across dozens of microservices, every backend service had to query that central session database to find out who the user was.

JWTs revolutionized microservice scalability by introducing **stateless verification**. Because the user's ID, roles, and expiration timestamp are embedded directly inside the token payload and cryptographically signed by the identity provider's private key, any backend microservice can verify the token's authenticity in microseconds using CPU math alone—with zero database lookups required.

The #1 Misconception About JWTs

Standard signed JWTs (JWS) are encoded, NOT encrypted! Anyone who intercepts or inspects a JWT can Base64URL-decode the Header and Payload in one millisecond without needing the secret key. Never store plaintext passwords, credit cards, or SSNs inside a JWT payload.

Anatomy of a JWT: The Three Dot-Separated Base64URL Segments

When you inspect an `Authorization: Bearer eyJhbGci...` header in your browser's DevTools, the token looks like a long string of random gibberish split into three parts by two period characters (`.`): `aaaaa.bbbbb.ccccc`. In reality, those three segments correspond to the **JOSE Header**, the **JWT Payload (Claims)**, and the **Cryptographic Signature**.

Notice that both the Header and the Payload almost always start with the letters `eyJ`. Why? Because in UTF-8 Base64 encoding, the three ASCII characters `{"a` or `{"t` (the opening curly brace and quote of a JSON object!) always encode to the prefix `eyJ`! Both segments are simply UTF-8 JSON objects encoded using **Base64URL** (RFC 4648 §5), which replaces URL-unsafe `+` and `/` characters with `-` and `_` and strips trailing `=` padding.

The third segment—the Signature—is calculated by concatenating the Base64URL-encoded Header and Payload with a period (`base64UrlHeader + "." + base64UrlPayload`) and passing that exact string through the cryptographic signing algorithm specified in the header, such as HMAC-SHA256 (`HS256`), RSA-SHA256 (`RS256`), or ECDSA (`ES256`).

text

Visual Breakdown of a Signed JWT (header.payload.signature)

1. HEADER (Algorithm & Token Type) -> Base64URL Encoded
{
  "alg": "RS256",
  "typ": "JWT",
  "kid": "auth-key-2026-04"
}

2. PAYLOAD (Registered & Custom Claims) -> Base64URL Encoded
{
  "sub": "usr_94810293",
  "name": "Alex Rivera",
  "role": "admin",
  "iat": 1775001600,
  "exp": 1775005200
}

3. SIGNATURE -> Raw Cryptographic Bytes (Base64URL Encoded)
RSASHA256(
  base64UrlEncode(header) + "." + base64UrlEncode(payload),
  privateKey
)

Decoding the Payload: Standard RFC 7519 Registered Claims Explained

To ensure interoperability across identity providers and API gateways, RFC 7519 defines seven short, three-letter **Registered Claim Names** inside the JWT payload. Understanding these three-letter keys is essential when debugging why an API is returning `401 Unauthorized` or `403 Forbidden`.

The three timestamp claims—`exp` (Expiration Time), `nbf` (Not Before), and `iat` (Issued At)—are always represented as `NumericDate` values: the number of **Unix epoch seconds** (not milliseconds!) elapsed since `1970-01-01T00:00:00Z` UTC. When debugging an expired token error, converting the `exp` and `iat` integers into human-readable local and UTC timestamps immediately reveals whether the token TTL has elapsed or if your server's NTP clock is skewed.

Alongside timestamps, `iss` (Issuer) identifies the auth server that minted the token, `sub` (Subject) stores the unique immutable user ID, `aud` (Audience) specifies which API service the token is intended for, and `jti` (JWT ID) provides a unique nonce identifier to prevent replay attacks.

  • `sub` (Subject): The unique identifier of the authenticated user or service account.
  • `exp` (Expiration Time): Unix timestamp (in seconds) after which the token must be rejected.
  • `iat` (Issued At): Unix timestamp (in seconds) recording when the token was minted.
  • `nbf` (Not Before): Unix timestamp before which the token is not yet valid.
  • `iss` & `aud` (Issuer & Audience): Prevent a token issued for Service A from being replayed against Service B.

Symmetric (HS256) vs. Asymmetric (RS256 / ES256 / EdDSA) Signatures

Why does the JWT header specify different algorithms like `HS256` versus `RS256` or `ES256`? `HS256` (HMAC with SHA-256) is a **symmetric** algorithm: the exact same secret string is used both to sign new tokens and to verify incoming tokens. While fast and simple for a single monolithic backend, symmetric signing becomes a security nightmare in microservice architectures because every downstream service that needs to verify a token must possess a copy of the master signing secret—meaning a compromise of any minor microservice allows an attacker to mint fake admin tokens!

By contrast, `RS256` (RSA-SHA256) and `ES256` (ECDSA using P-256) are **asymmetric public-key** algorithms. Only the central Identity Provider holds the fiercely guarded **Private Key** capable of signing tokens. Every downstream API service fetches the publicly visible **Public Key** (typically published at `/.well-known/jwks.json`). Downstream services can mathematically verify that a token is authentic, but they can never forge a new signature.

Classic JWT Security Vulnerabilities Every Developer Must Prevent

Because JWTs grant direct access to protected APIs, improperly configured JWT verification middleware has caused some of the most famous authentication bypass vulnerabilities in web history. The most notorious flaw is the **`"alg": "none"` attack**: early JWT libraries trusted the `alg` field inside the incoming untrusted token header. If an attacker modified the payload to `"role": "superadmin"`, changed the header to `"alg": "none"`, and stripped the signature after the second dot, vulnerable servers treated the unsigned token as valid!

A second critical vulnerability is **Algorithm Confusion (RS256 to HS256 downgrade)**: if a server normally verifies tokens using a public RSA key (`RS256`), an attacker can change the token header to `HS256` and sign the forged token symmetrically using the server's publicly downloadable RSA public key string as the HMAC secret. Always hardcode an explicit allowlist of expected algorithms (e.g., `algorithms: ['RS256']`) in your backend verification function.

Why Production Bearer Tokens Must Only Be Decoded Locally

During a live production outage, developers frequently grab an active `Authorization: Bearer` JWT from Sentry logs or Chrome DevTools and paste it into an online debugger to inspect its claims and `exp` timestamp. If that website logs requests or analytics payloads on a remote server, you have just handed a live, valid authentication credential to a third party!

Using a strictly client-side JWT Decoder guarantees that `atob()` Base64URL decoding, claim inspection, and live expiration countdowns execute exclusively inside your local browser tab—keeping your staging and production credentials 100% isolated.

Token Lifetime Best Practice

Keep stateless JWT Access Tokens short-lived (5 to 15 minutes) so permissions and revocations take effect quickly, and pair them with an HttpOnly, Secure, SameSite=Strict Refresh Token that can be revoked server-side.

Article FAQ

Frequently Asked Questions

Can I decode a JWT without knowing the secret key?+

Yes! The Header and Payload of a standard JWT (JWS) are simply Base64URL-encoded JSON strings. Anyone can decode and read the contents of a JWT without the secret key. The secret or private key is only required to verify that the signature was not tampered with or to sign a new token.

What happens if someone edits the role claim in a decoded JWT and re-encodes it?+

If an attacker decodes your JWT, changes `"role": "user"` to `"role": "admin"`, and Base64URL-encodes the modified payload, the cryptographic hash of the payload changes completely. Because the attacker does not have your server's secret signing key, the existing signature in the 3rd segment will fail verification and the server will reject the token.

Why does my JWT `exp` timestamp look like a 10-digit number instead of a date?+

Per RFC 7519, JWT timestamps (`exp`, `iat`, `nbf`) are stored as Unix Epoch time in seconds (10 digits), whereas JavaScript's `new Date()` constructor expects milliseconds (13 digits). Multiply the `exp` value by `1000` in JavaScript, or paste the token into our JWT Decoder to view human-readable dates automatically.

Where should I store JWTs in the browser: localStorage or HttpOnly cookies?+

Security architects strongly recommend storing sensitive session and refresh tokens in `HttpOnly; Secure; SameSite=Lax/Strict` cookies rather than `localStorage`, because `localStorage` is immediately readable by any malicious Cross-Site Scripting (XSS) script or compromised npm dependency.

Is it safe to paste a live production JWT into this JWT Decoder?+

Yes. Our JWT Decoder runs 100% client-side in your browser's local JavaScript memory with zero network transmissions, telemetry, or server logging.

Written & Reviewed By

Sophia Lindqvist — Principal Application Security Engineer

Sophia leads penetration testing and identity authentication architecture for cloud infrastructure teams, specializing in OAuth 2.0, OIDC, and WebCrypto standards.

Try the Related Free Online Tools

More Guides You Might Like