7 min read

How to Decode a JWT

Understand JWT segments, inspect claims, and avoid confusing decoding with signature verification.

The three JWT segments

A typical signed JWT contains a header, payload, and signature separated by periods. The first two segments are Base64URL-encoded JSON and are readable by anyone who has the token.

The header commonly contains an algorithm (alg) and token type (typ). The payload contains claims such as sub for the subject, iss for the issuer, aud for the intended audience, iat for issue time, and exp for expiry. These names are useful conventions, but their meaning still depends on the service that issued the token.

Header:  {"alg":"HS256","typ":"JWT"}
Payload: {"sub":"user-123","aud":"api","exp":1893456000}
Token:   eyJhbGciOi...eyJzdWIiOi...signature

Decoding is not verification

Decoding reveals claims; it does not prove who created the token or whether it was changed. A trusted server must verify the signature, expected issuer, audience, algorithm, and relevant time claims before authorization.

A decoder can help diagnose a token that is missing a claim, has an unexpected audience, or has already expired. It cannot tell you whether the signing key is trusted. Verification requires the issuer's documented key and policy, usually through a server-side JWT library or the identity provider's middleware.

Handle tokens carefully

Access tokens can grant real privileges. Avoid sharing them in tickets, screenshots, chat messages, or public tools that upload input.

Even though DevKitly's decoder processes the input locally in the browser, do not paste a live production token into a shared computer, screen recording, browser history, or support ticket. Prefer a revoked test token with its claims anonymized.

A practical inspection workflow

Copy the complete token, including all periods, into the JWT Decoder. Inspect the header and payload separately, then compare iss, aud, and exp with the API documentation. If the token has only two segments, it may be an unsecured or malformed token; do not assume it is trustworthy.

Use the timestamp converter when an iat or exp value is difficult to read. Unix timestamps in JWT claims are normally seconds since 1970-01-01T00:00:00Z, while JavaScript Date values often use milliseconds. A factor-of-1,000 mistake can make a valid expiry appear far in the future or already expired.

Common mistakes and limits

JWT payloads are encoded, not encrypted. Anyone who receives the token can decode the claims, so never store passwords, private keys, or confidential records in the payload. Use encrypted tokens only when the protocol and key management explicitly require them.

Do not change alg in a token and treat the result as verified, accept an algorithm that the server did not configure, or rely on the browser decoder for access control. The actual authorization decision must happen in the trusted service that verifies the token.

Try the JWT Decoder