A JWT decoder can reveal a token’s header and claims in seconds, but decoding is not the same as proving that a token is authentic. This guide provides a reusable checklist for inspecting JWTs, verifying signatures, checking important claims, troubleshooting API authentication, and handling tokens without exposing sensitive credentials.
Overview
JSON Web Tokens (JWTs) are compact strings commonly used to carry authentication and authorization data between an application and an API. A signed JWT usually contains three Base64URL-encoded sections separated by periods: a header, a payload, and a signature.
- Header: Describes the token type and signing algorithm, such as
typandalg. A key identifier,kid, may also indicate which verification key the issuer expects you to use. - Payload: Contains claims, which are statements about the token or its subject. Claims can include an expiration time, issuer, audience, user identifier, or permissions.
- Signature: Allows a verifier to check whether the signed content was altered and whether it was produced with a trusted key.
When someone asks how to decode a JWT token, they often mean reading the first two sections. That operation is useful for debugging, but it does not confirm that the token is valid. The payload is encoded rather than encrypted in a typical signed JWT, so anyone who possesses the token may be able to read its claims. A JWT should therefore never contain secrets, passwords, private keys, or other data that clients are not allowed to see.
Use a JWT token debugger or browser-based JWT decoder only with non-sensitive sample data. For production tokens, prefer a local command-line utility, a controlled development environment, or the JWT library already used by your application. Related API troubleshooting workflows can also benefit from an online JSON formatter and validator workflow, provided the data is safe to share.
Checklist by scenario
Scenario 1: You need to inspect a token
- Confirm the token format. A signed JWT normally has three dot-separated segments. A token with a different structure may be opaque, encrypted, malformed, or part of another authentication format.
- Work on a safe copy. Remove or replace production values where possible. Do not paste an active access token into an unfamiliar website, browser extension, chat, issue tracker, or support ticket.
- Decode the header and payload. A local JWT decoder can Base64URL-decode the first two segments without needing a secret or public key. Treat every displayed value as untrusted input.
- Record the relevant claims. Note the issuer, audience, subject, expiration, not-before time, issued-at time, token ID, and any application-specific roles or scopes.
Scenario 2: You need to verify a JWT signature
- Identify the expected algorithm. The algorithm named in the token header is an input, not an instruction your application should blindly accept. Configure the verifier with an explicit allowlist that matches the issuer’s documented algorithm.
- Use a trusted verification key. For asymmetric signing, verification normally uses a public key obtained through a trusted configuration or key-distribution process. For symmetric signing, the verifier needs the correct shared secret, which must remain server-side.
- Verify before trusting claims. Do not authorize a request based on decoded roles, scopes, or user IDs until the signature has passed verification and the token has passed claim validation.
- Validate the issuer and audience. Check that
issmatches the expected identity provider andaudidentifies your API or service. A valid token issued for a different application may still be inappropriate for your endpoint. - Handle key rotation deliberately. If the header includes
kid, use it only to select among trusted keys. Never fetch arbitrary keys from an untrusted location based solely on a token value.
Scenario 3: An API request is failing
- Check whether the token is actually being sent in the expected
Authorization: Bearerheader or authentication mechanism. - Compare the current time with
expandnbf. JWT timestamps are commonly represented as numeric seconds, so confirm that your library and test code interpret them correctly. - Check for clock differences between the client, API, and identity provider. If a small tolerance is supported by your library, keep it deliberate and limited rather than using a broad window to hide configuration errors.
- Inspect the API response separately from the token. A
401commonly indicates missing or invalid authentication, while a403may indicate that authentication succeeded but authorization did not. Review the HTTP status code troubleshooting guide for a broader diagnostic workflow. - Compare the token’s scopes or roles with the permission required by the endpoint. A correctly signed token can still lack authorization.
Choose the right JWT inspection method
| Method | Best for | Main caution |
|---|---|---|
| Browser-based decoder | Quick inspection of deliberately fake or non-sensitive tokens | Do not disclose live credentials or assume decoding verifies authenticity |
| Command-line tool | Repeatable local debugging and shell-based workflows | Protect shell history, logs, process arguments, and copied output |
| Application library | Signature verification and production validation | Configure algorithms, keys, issuer, audience, and time checks explicitly |
What to double-check
Claims are only meaningful in the context of the service that issued and consumes the token. Use this review list before treating a decoded JWT as evidence of identity or permission.
exp: Reject tokens that are past their expiration time.nbf: Reject or defer tokens that are not valid yet, subject to a carefully controlled clock policy.iat: Use it as context or for policy checks only when your application has a clear reason to do so.iss: Require the expected issuer; do not accept any issuer merely because the signature is valid.aud: Require the intended API or service audience. Remember that this claim may be a string or an array depending on the issuer and library.sub: Treat the subject as an identifier, not automatically as an authorization decision.scope, roles, and permissions: Map them to server-side authorization rules rather than trusting a client-side display or UI state.jti: Consider whether token identifiers are needed for replay detection, revocation, or audit workflows.
Also double-check the token type. A signed JWS and an encrypted JWE may require different processing. If the application must support encrypted tokens, use a library and configuration designed for that format rather than treating encrypted content as an ordinary readable payload.
Keep verification logic centralized where possible. Duplicated JWT checks across controllers and services can drift over time, causing one endpoint to accept tokens that another rejects. Document the expected issuer, audience, algorithms, key source, claim requirements, and error behavior alongside the API contract. An OpenAPI workflow can help keep authentication expectations visible to the team.
Common mistakes
- Confusing decoding with verification: Anyone can often decode a JWT payload. That does not prove who created it or whether it was modified.
- Trusting the algorithm in the header: The verifier should enforce an expected algorithm rather than accepting whatever the token announces.
- Using a decoded role as authorization: Claims must be accepted only after signature, issuer, audience, and time validation.
- Logging complete tokens: Access tokens in application logs, analytics events, screenshots, or error reports can become credentials. Redact them and limit diagnostic output.
- Putting secrets in the payload: Encoding is not encryption. Use server-side storage or an appropriate encryption design for confidential values.
- Ignoring key rotation: Verification code should accommodate an intentional key lifecycle without accepting unknown or attacker-selected keys.
- Assuming JWTs solve session management: Token lifetime, refresh behavior, revocation, storage, and logout remain application design decisions. Review the deployment and environment-variable controls in this web app deployment checklist before releasing authentication changes.
When to revisit
Return to this checklist whenever authentication behavior changes, not only when an API starts returning errors. Recheck the implementation before rotating signing keys, changing identity providers, adding a new audience, introducing a new service, modifying scopes or roles, or upgrading the authentication library.
During a scheduled review, create safe test tokens for expired, not-yet-valid, wrong-issuer, wrong-audience, altered-signature, missing-claim, and insufficient-scope cases. Confirm that the API rejects each case as intended and that logs do not expose full credentials. Review browser-based debugging guidance as tools and team workflows change; production tokens should remain in controlled environments.
For a practical final pass, ask four questions: Was the token decoded only for inspection? Was its signature verified with a trusted key and explicit algorithm? Were issuer, audience, time, and authorization claims checked? Could any token or secret have leaked during debugging? If the answer to all four is clear, your JWT troubleshooting process is more likely to separate harmless inspection from security-critical validation.