API Security

Decode JWTs Safely Without Cloud Debuggers

A JWT in your clipboard is a live credential. Here is how we read claims, check expiry, and verify signatures without handing the token to a stranger’s server.

A few months ago a customer wrote in on a Friday afternoon. They could log in, but every call to the reporting API came back with a 401. One of our developers grabbed the bearer token from the customer's HAR file, opened a browser tab, typed "jwt decode" into the search bar, and pasted the token into whatever came up first. The payload showed the answer in about four seconds: the token had been issued for the wrong audience.

Problem solved. Except that token was still valid for another eleven hours, it belonged to an account with admin rights, and we had just handed it to a website none of us knew anything about. We never saw any sign of misuse. But "we never saw any sign" is a weak thing to rely on when an admin session is involved, and I have not been comfortable with that shortcut since.

This post is the process we use now. It is not complicated, and it doesn't slow you down.

Why a pasted token is a leaked token

Most JWTs you debug are bearer tokens. The server doesn't ask who is holding the token. It checks the signature, checks the expiry, and lets the request through. So anyone who has a copy of a live token can act as that user until it expires.

When you paste a token into an online debugger, you have no idea what happens next. The page might decode it purely in JavaScript. It might also send it to a backend, write it to request logs, pass it through an analytics script, or cache it somewhere. An honest site can still have a leaky third-party script. You can't tell from the outside, and the payload usually carries more than you'd expect: email addresses, internal user IDs, tenant names, role lists.

Treat a token like a password with an expiry date. You wouldn't paste a password into a random form to check its length.

What you are actually looking at

Look closely at any token and you will spot two periods splitting it into sections. Section one and section two are JSON objects run through Base64URL. Section three is the signature that ties them together.

The header is small and tells you how the token was signed:

{ "alg": "RS256", "typ": "JWT", "kid": "2026-key-a" }

The payload holds the claims, which is where the debugging answers usually live:

{
  "iss": "https://auth.example.com/",
  "sub": "user_48213",
  "aud": "reports-api",
  "scope": "reports:read",
  "iat": 1790496000,
  "exp": 1790499600
}

A common misunderstanding is that the scrambled-looking text is protected in some way. It isn't. Base64URL only turns JSON into URL-safe characters, and reversing it takes a single function call. So decoding a JWT requires no key, and whatever sits in the claims is readable by every proxy, log file, and browser extension the token passes through. Keep passwords, API keys, and anything sensitive out of them.

The signature is what proves the header and payload weren't changed after the auth server issued them. Reading the payload tells you what the token claims. Only the signature check tells you whether to believe it.

How we decode tokens without them leaving the laptop

  1. Open JWT Decoder and paste the token. The decoding runs in your browser tab. If you want proof, open DevTools, switch to the Network panel, and paste again. You won't see a request go out.
  2. Look at the header first. Note the alg and the kid. If the key ID doesn't match anything your auth provider publishes, you already have a lead.
  3. Paste the same token into JWT Expiration Checker. The exp, nbf, and iat values are Unix timestamps in seconds, and converting 1790499600 to a date in your head is not a good use of anyone's afternoon. The checker turns them into plain dates and tells you whether the token is still usable, which often ends the investigation on the spot.
  4. If you need to confirm the token is genuine, use JWT Verify with the public key or shared secret. Keep this step local too, since an HS256 secret is exactly what an attacker wants.

If you live in a terminal, you can read the payload with a one-liner that splits on the dots and Base64-decodes the middle part. Just remember that Base64URL drops padding and swaps two characters, so plain base64 -d sometimes complains. A browser tool handles that for you.

The claims that explain most 401s

Nearly every "valid token, still rejected" ticket we have seen came down to one of these:

  • Expired token. Obvious, but it is still the most common cause. Look for a frontend that caches an access token and never refreshes it.
  • Clock skew. A container with a drifting clock can reject a token issued a few seconds "in the future" because of nbf. Most libraries allow a small leeway. Check that yours does.
  • Wrong audience. The token was issued for one API and sent to another. That was our Friday bug.
  • Issuer mismatch. A staging token sent to production, or the other way around. The iss value shows it right away.
  • Missing scope. The user is authenticated, but the token lacks the permission the endpoint wants. Strictly that should be a 403, but plenty of APIs return 401 anyway.

Decoding is not verifying

This deserves its own section because it causes real security bugs. Anyone can create a JWT with any payload they like. Without checking the signature, "role": "admin" in a payload means nothing.

Symmetric algorithms like HS256 use one shared secret to sign and to verify. Asymmetric ones like RS256 and ES256 sign with a private key and verify with a public key, usually fetched from the provider's JWKS endpoint. Your server code should pin the algorithms it accepts rather than trusting whatever the header says. Older libraries were caught out by tokens that switched alg to none, or swapped RS256 for HS256 and used the public key as the HMAC secret.

Red flags worth raising in code review

  • A header with alg: none, or an algorithm your system never issues.
  • Access tokens that live for days instead of minutes.
  • Personal data in claims that the API never reads.
  • Scopes like * or admin on tokens handed to browser apps.
  • Servers that decode the token and use the claims without verifying anything.

Clean up after yourself

Once you have your answer, close the tab and clear your clipboard. Don't paste the full token into a ticket, a Slack thread, or a pull request comment. If a colleague needs to see it, share the decoded claims and leave out the signature. If you think a live token did end up somewhere public, revoke the session or rotate the key. Waiting for it to expire is hoping, not a plan.

Where to go next

For a longer, step-by-step version, read Debug JWT in your browser. The JWT topic hub covers the concepts in more depth, and the JWT workflow chains decode, expiry, and verify into one private flow.

Frequently asked questions

Is it safe to paste a JWT into an online decoder?

Only if the token is expired or from a test environment. A live token can be used by anyone who has a copy until it expires, and you cannot see what an online site does with the text you paste. Decode real tokens with a tool that runs in your browser.

Can you decode a JWT without the secret key?

Yes. The header and payload are only Base64URL-encoded, so anyone can read them. The key is needed to verify the signature, which proves the token was issued by your auth server and not altered.

Why is my JWT rejected when it has not expired?

The usual causes are a wrong audience (aud), an issuer mismatch between environments (iss), a missing scope, or clock skew between servers affecting the nbf check.

What does alg none mean in a JWT header?

It means the token is unsigned. Servers should reject it unless unsigned tokens are explicitly intended, which is almost never the case in production.

Sources and further reading

← All posts Browse tools