A JWT decoder can show you what a token contains, but it cannot prove that the token is authentic. This guide explains the difference between decoding and verification, then provides a reusable checklist for inspecting JWTs safely during API authentication and debugging.
Overview
JSON Web Tokens (JWTs) are compact strings commonly used to carry claims between an identity provider, an application, and an API. A typical signed JWT has three dot-separated parts: a header, a payload, and a signature.
A JWT decoder reads the header and payload so you can inspect their JSON content. The header may identify the token type and signing algorithm. The payload may contain claims such as a subject identifier, issuer, audience, issued-at time, and expiration time. Decoding is usually a formatting operation: it does not establish that the token came from a trusted issuer or that its claims should be accepted.
A JWT verifier performs a security check. It validates the signature with an appropriate secret or public key and, depending on the library and configuration, checks claims such as the issuer, audience, expiration, and not-before time. Verification must also enforce an expected algorithm rather than blindly trusting an algorithm value supplied by the token.
This distinction matters because the payload is not necessarily confidential. In many JWT implementations, the header and payload are Base64URL-encoded rather than encrypted. Anyone who obtains the token may be able to read them. Treat a JWT as a credential while it is valid, even when its visible claims do not look sensitive.
For related formatting work, a JSON formatter and validator can make decoded claims easier to inspect. For a broader workflow, see How to Decode and Validate JWTs Safely.
Checklist by scenario
When you need to inspect a token
- Confirm the source. Work from a local development token, a deliberately redacted sample, or a test environment whenever possible. Do not paste production access tokens into an unfamiliar browser-based tool.
- Check the structure. A signed JWT normally has three sections separated by periods. If the token has a different structure, it may be opaque, encrypted, malformed, or not a JWT at all.
- Decode without assuming trust. Use a local script, a reviewed command-line utility, or a browser-based JWT decoder only with safe data. Inspect the header and payload as untrusted input.
- Record useful claims. Note the issuer, audience, subject, token identifier, issued-at time, expiration, and any scope or role claims relevant to the failing request. Avoid copying the complete token into tickets or chat messages.
When an API request returns an authentication error
- Compare clocks and time claims. Check whether
exphas passed, whethernbfis in the future, and whether the issuing system and API disagree about time. A token can be correctly signed and still be unusable because it is outside its accepted time window. - Check the audience. The
audclaim should identify the API or resource that is validating the token. A token issued for one service may be rejected by another. - Check the issuer. The
issvalue should match the identity provider configured by the API. Similar-looking development and production issuer URLs are a frequent source of confusion. - Check the key and algorithm configuration. The verifier must use the expected key material and an explicitly allowed algorithm. A decoded header can show the declared algorithm, but only the verifier can determine whether the signature matches.
- Inspect the request itself. Confirm that the token is sent in the expected authorization header or cookie, without extra quotation marks, whitespace, truncation, or accidental URL encoding.
When implementing verification
- Use a maintained JWT library rather than writing signature validation from scratch.
- Configure an allowlist of acceptable algorithms and the expected issuer, audience, and signing key.
- Separate authentication from authorization. A valid signature identifies a trusted token source; it does not automatically grant every action.
- Handle verification failures without returning secrets, key details, or unnecessary token contents in error messages.
- Keep signing keys out of source control, client-side code, logs, screenshots, and online inspection tools.
What to double-check
Start with the header, but do not treat it as an instruction. Values such as alg, typ, and kid are useful for diagnosis, yet they come from the token and must be validated against server configuration. In particular, an application should not accept any algorithm simply because the token names it.
Next, inspect the payload's time claims. iat indicates when the token was issued, while exp defines when it should stop being accepted. nbf, when present, defines a point before which it should not be accepted. These values are normally represented as numeric dates. Confirm that your library validates them and that any clock-skew allowance is intentional rather than an undocumented workaround.
Then verify identity and scope assumptions. The sub claim may identify a user or service, but your application should interpret it according to its own documented contract. Roles, permissions, and scopes should be checked at the endpoint or service boundary that needs them. Do not rely on a front-end display of a role as proof that a back-end operation is authorized.
Finally, review exposure. Remove or mask the signature and token body before sharing debugging output. If a real token was exposed, treat that exposure as a security event according to your application's procedures: revoke or replace it when possible, review relevant logs, and avoid reusing it for testing. A decoder cannot make a leaked credential safe.
Common mistakes
- Confusing decoding with verification. Readable claims prove only that the token can be parsed, not that they are genuine.
- Using production tokens in public tools. Even a reputable online developer tool may be the wrong place for credentials covered by your organization's rules.
- Trusting client-side claims. A browser can decode and display a token, but authorization decisions belong on the server or protected API.
- Checking expiration only in the interface. Client-side expiration handling improves user experience; it must not replace server-side validation.
- Ignoring audience and issuer. A valid signature from a trusted provider does not mean the token was intended for your API.
- Logging complete authorization headers. Debug logs can outlive the original request and may be accessible to more people than expected.
- Assuming every token is a signed JWT. Some systems use opaque tokens or encrypted formats. Follow the contract for the specific authentication system instead of forcing every value through a decoder.
If you are diagnosing a malformed payload rather than an authentication issue, format the JSON separately and validate it before investigating application logic. For adjacent debugging workflows, the online developer tools toolkit and regex tester guide can help with safe, non-secret test data.
When to revisit
Revisit this checklist whenever an identity provider, API gateway, authentication library, signing key, or token contract changes. It is also useful before seasonal planning cycles, major releases, environment migrations, and changes to logging or support workflows. Those are practical points to confirm that development, staging, and production use the intended issuer, audience, algorithms, keys, and claim rules.
Make the review actionable: keep a redacted sample token for each supported environment, document the expected claims, list the algorithms and key sources accepted by each service, and test expired, not-yet-valid, wrong-audience, wrong-issuer, malformed, and invalid-signature cases. Review who can access debugging logs and whether support instructions tell people to remove credentials before sharing output.
When a JWT decoder shows an unexpected value, use it to form a question, not to make a trust decision. The final checklist is simple: decode only safe samples, verify with the server's configured keys and rules, validate time and audience claims, enforce authorization separately, and treat exposed tokens as credentials that may need to be revoked.