Your API just answered 401, and the token in your header looks fine: right length, right shape, copied from the right place. Most token rejections come from a short list of causes, and they look identical from the outside. A damaged copy, an expired token and a bad signature all produce the same flat rejection.

Debugging works when you separate the causes a token can answer about itself from the one cause it cannot. The free JWT Decoder on Ovatly handles the first group: it shows the header and payload in plain JSON and translates the expiry into a readable date and verdict. The second group has exactly one member: the signature.

Contents

  • Quick answer
  • Start with the shape: three segments or not a token
  • Cause one: the copy is damaged
  • Cause two: the token has expired
  • Cause three: the signature does not match
  • How to debug a rejected token, step by step
  • Worked example: reading a rejected token
  • Limitations: what a decoder cannot tell you
  • Common mistakes
  • FAQs
  • Conclusion

Quick answer

Paste the full token, all three dot-separated parts, into the JWT Decoder. If it does not decode into readable JSON, the problem is format: a missing segment, a truncated copy or corrupted characters. If it decodes, read the payload claims and check the expiry panel. An expired verdict explains a rejection on the token's own terms. If the token decodes and is not expired, the remaining suspect is the signature, and only the issuing server can confirm that, because verification needs the signing key or the issuer's public key.

Start with the shape: three segments or not a token

A JWT is three segments joined by dots: header, payload, signature. That shape is the first diagnostic. A token missing a segment, or carrying an extra one, is not in JWT shape, and no server will accept it. This catches a large share of real-world failures, because tokens get copied out of places never designed to hold them: log lines that wrap, terminals that trim, chat messages that swallow characters.

So the first debugging question is not about cryptography. It is whether the string you are sending is the complete token, character for character.

Cause one: the copy is damaged

A truncated paste is the classic format error. The token gets copied from the middle of a line, or the tail is cut off, and the result still looks like a token. Corrupted characters do the same damage more quietly: the segments are all present, but what is inside them no longer decodes into readable JSON.

The decoder reveals both problems the same way: the token fails to produce a readable header and payload, which puts the fault in the copy, before expiry or signature even arise. The fix is unglamorous: copy the full token, all three dot-separated parts, from the source and decode again. If the fresh copy decodes cleanly, you have found your bug.

Cause two: the token has expired

If the token decodes, the next suspect is time. The payload's exp claim is the expiry, expressed as seconds since the Unix epoch, and the expiry panel translates it into a readable date with a clear expired or not-expired verdict. An expired verdict is a complete explanation for a rejection: the token is past its own deadline.

Two wrinkles belong here. First, tokens without an exp claim are reported as having no expiry of their own, which is common for some API tokens; for those, expiry cannot be the cause the token shows you. Second, verdict and enforcement are different things. The tool reports the claim exactly, but your server's policy decides what is enforced. Some systems allow clock skew leeway of a minute or two, and some ignore exp for specific flows, so a token can read as expired here while an app still accepts it.

Cause three: the signature does not match

Suppose the token is complete, decodes cleanly, and is not expired, and the API still says invalid. The remaining cause is the signature, the one question a decoder cannot answer.

The signature is the segment the issuer produced with a secret or a private key. Verification means checking it with the signing key or the issuer's public key, and a decoder page has neither. That is why the JWT Decoder labels the signature as not verified. A decoded payload is a claim, not a proof: anyone can build a token with any payload, sign it with a key they invented, and it will decode beautifully and fail verification instantly.

So treat a signature failure as a server-side finding. The decoder's contribution is narrower: it shows you exactly what the token claims, so you can hand the server side a precise question. Is this the issuer you expected? Is this the subject the request is about? If the claims match and the token is in date, the mismatch lives in verification, and only the issuer's check can settle it.

How to debug a rejected token, step by step

  1. Paste the full token, all three dot-separated parts, into the JWT Decoder. If it does not decode, recopy it and try again.
  2. Read the decoded header, which names the algorithm and token type.
  3. Read the payload claims: subject, issuer, issued-at and expiry, and check they match the request that was rejected.
  4. Check the expiry panel for the verdict, and remember the signature warning: if the token is in date and the claims are right, the rejection is a verification or policy question.

Worked example: reading a rejected token

Take the classic demo token. Its header decodes to {"alg":"HS256","typ":"JWT"}. Its payload contains sub "1234567890", name "John Doe" and iat 1516239022. It carries no exp claim, so the decoder reports it as having no expiry of its own.

Run the debugging order on it. Shape: three segments, intact. Claims: readable. Expiry: none of its own, so expiry cannot be the cause this token can show. Now add an exp claim of 4000000000 and the panel reports expiry on 2 October 2096, so the token is not expired either. If a server rejected a token in this state, every testifiable cause has been cleared, and what remains is the signature, which only that server can judge.

Limitations: what a decoder cannot tell you

Decoding is not verification. The tool cannot confirm a token is genuine, cannot confirm a signature failure, and cannot see your server's policy on clock skew or ignored exp claims. It reports the exp claim exactly; enforcement is the server's decision.

What it can do is show you the token's own testimony: the header's algorithm and type, the payload's claims, and an expiry verdict computed from the exp and iat claims, which are seconds since the Unix epoch. Everything happens locally, because tokens are credentials and this page never uploads your token. Treating tokens like passwords, and keeping them out of public places and screenshots, is still your job.

Common mistakes

  • Assuming a decoding failure means a bad signature. If the token does not decode, the copy is damaged. Signatures are judged by servers, not decoders.
  • Debugging the signature first. Work in order: shape, copy, claims, expiry.
  • Pasting a fragment and trusting the result. A token copied from a wrapped log line may be missing characters. Always decode the full token, all three parts.
  • Reading epoch times by eye. Exp and iat are seconds since the Unix epoch. Let the panel translate them.
  • Treating a decoded payload as proof. It is a claim. A forged token decodes just as neatly as a genuine one.

FAQs

Can the decoder tell me whether my signature is valid? No. Verification needs the secret or public key used for signing, which a decoder page does not have. The tool labels the signature as not verified. Only the issuing server can confirm a signature failure.

My token decodes fine but the API still rejects it. Why? Then the likely causes sit on the server side: the signature does not verify against the issuer's key, or the server's policy rejects something in the claims. The decoder shows you exactly what the token claims.

The decoder says expired, but the app still accepts my token. Which is right? Both. The tool reports the exp claim exactly. Some systems allow clock skew leeway of a minute or two, and some ignore exp for specific flows. Your server's policy decides what is enforced.

What if my token has no exp claim? The decoder reports it as having no expiry, which is common for some API tokens. If such a token is rejected, expiry is not the cause; look at the signature or the server's policy.

What format problems can I spot myself? The ones visible in the token itself: a missing or extra segment, a truncated paste, or characters corrupted in copying so the segments no longer decode. If the full token does not decode, the problem is the copy, not the signature.

Conclusion

Invalid usually means one of three things: the copy is damaged, the token's exp claim has passed, or the signature fails a check only the issuing server can run. The JWT Decoder settles the first two and shows you the exact claims behind the third, while labelling the signature as not verified. For the structure behind this order, read the companion guide: JWT Structure Explained.

More tools for this kind of work live in the Developer Tools archive.