Skip to content
Back to all articles
Developer4 min readNovember 3, 2026

How to Decode and Verify a JWT (and Debug 401 Errors)

Read a JSON Web Token’s header and claims, check exp, iat and nbf, and verify the signature with a secret or public key, safely in your browser.

How to Decode and Verify a JWT (and Debug 401 Errors) article
In this guide
  1. What a JWT looks like
  2. Step 1: decode the token
  3. Step 2: read the standard claims
  4. Step 3: check the status
  5. Step 4: verify the signature
  6. Common 401 causes, and what the token shows
  7. Security checklist for JWTs
  8. Related tools
  9. Summary

Your API returns 401 Unauthorized and the only clue is a long string starting with eyJ. That string is a JSON Web Token (JWT), and it usually tells you exactly what is wrong, once you can read it.

This guide explains what is inside a JWT, how to decode it, how to check its times, and how to verify its signature. Everything below can be done in the free JWT Decoder & Inspector, which runs in your browser.

What a JWT looks like

A JWT is three parts separated by dots:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 . eyJzdWIiOiIxMjMiLCJleHAiOjE3OTM3MzY3ODB9 . 4pcPyMD09olPSyXnrXCjTwXyr4BsezdI1AVTmud2fU4
          header                                  payload                                  signature
  • The header says which algorithm signed the token, for example {"alg":"HS256","typ":"JWT"}.
  • The payload holds the claims: who the user is, who issued the token and when it expires.
  • The signature proves the header and payload were created by someone with the key and have not been changed.

The header and payload are only Base64URL-encoded, not encrypted. Anyone can read them. That is why you must never put passwords or secrets in a JWT.

Step 1: decode the token

Paste the token into JWT Decoder. You can paste the bare token or a whole Authorization: Bearer … header; the prefix is removed automatically. The header and payload are shown as formatted JSON.

Step 2: read the standard claims

ClaimMeaningWhat to check
issIssuerIs it your auth server (and the right environment)?
subSubject, usually the user IDIs it the user you expected?
audAudienceDoes it match the API that rejected it?
expExpiry timeIs it in the past?
nbfNot valid beforeIs it in the future?
iatIssued atDoes it look right, or is a clock wrong?
jtiToken IDUseful for revocation lists.

Times are Unix timestamps (seconds since 1 January 1970). The inspector shows them as dates in your time zone and as "3 hours ago" or "in 10 minutes", which is much easier than converting them by hand.

Step 3: check the status

The status bar shows one of three states:

  • Expired: exp has passed. The client should have refreshed the token.
  • Not yet valid: nbf (or iat) is in the future. Usually a server clock is ahead.
  • Not expired: the times are fine, so look elsewhere.

"Not expired" does not mean "genuine". That needs the signature check.

Step 4: verify the signature

Anyone can write a token with any payload; only the signature shows it is real. Enter the key in the inspector:

  • HS256, HS384, HS512 (HMAC): the shared secret your server signs with.
  • RS256-512, PS256-512 (RSA) and ES256-512 (ECDSA): the public key in PEM format (-----BEGIN PUBLIC KEY-----). Identity providers publish it, often as a JWKS; convert the key you need to PEM.

The result appears immediately: Signature verified, or Invalid signature, meaning the key is wrong or the token was changed.

The token and key are processed with your browser's Web Crypto API and never sent anywhere. Even so, use test tokens where you can, and never paste other people's live tokens into any website.

Common 401 causes, and what the token shows

  1. Expired token. The status says Expired. Fix the refresh logic, or check that the client uses the new token after refreshing.
  2. Wrong audience. aud is for a different API, for example a token for the web app sent to the orders service.
  3. Wrong environment. iss is the staging auth server but the request went to production, or the other way round. Verification with the production key fails.
  4. Clock skew. iat or nbf is a few minutes in the future. Sync server clocks (NTP) or allow a small leeway.
  5. Missing permission. The token is valid, but the scope or role claim lacks what the endpoint needs.
  6. Header format. The API expects Authorization: Bearer , but the client sent the token without "Bearer", or in a cookie.

Security checklist for JWTs

  • Always verify signatures on the server, with a fixed list of allowed algorithms.
  • Reject alg: none. The inspector flags these tokens as unsigned.
  • Keep access tokens short-lived (minutes) and use refresh tokens for long sessions.
  • Do not store secrets in the payload. It is readable by anyone.
  • Use HTTPS everywhere, so tokens cannot be read in transit.

Summary

To debug a JWT, paste it into the JWT Decoder & Inspector, read the claims, check whether it is expired or not yet valid, and verify the signature with the secret or public key. Most 401 errors turn out to be an expired token, the wrong audience or issuer, clock skew or a missing permission, and the decoded token shows which.

Was this article helpful?

Found this guide useful?

Share it with someone who is struggling with the same problem.

Free tool · No sign-up

JWT Decoder & Inspector

Decode a JSON Web Token to see the user, roles, scopes and expiry, check it for security problems, and verify its signature with a secret, PEM key or JWKS.

Open tool

Written by

Hemant Adhikari HemantInsights

Senior Software Engineer · Developer of Toolyconvert

I’m a senior software engineer from Dehradun, India, building websites since 2014. I designed and developed Toolyconvert, from the Next.js front end and headless WordPress back end to the tools themselves, and I review every guide before it goes live.