JWT Decoder

Free Online JSON Web Token Debugger & Explainer

Understanding JSON Web Tokens (JWT)

JSON Web Token (JWT) is a compact, URL-safe means of representing claims to be transferred between two parties. The claims in a JWT are encoded as a JSON object that is used as the payload of a JSON Web Signature (JWS) structure or as the plaintext of a JSON Web Encryption (JWE) structure, enabling the claims to be digitally signed or integrity protected with a Message Authentication Code (MAC) and/or encrypted.

How a JWT is Structured

In its compact form, JSON Web Tokens consist of three parts separated by dots (.), which are:

The Formula Behind JWT

The output is typically three Base64-URL strings separated by dots. The structure looks like this:

base64UrlEncode(header) + "." + base64UrlEncode(payload) + "." + signature

To create the signature:

HMACSHA256(
  base64UrlEncode(header) + "." +
  base64UrlEncode(payload),
  secret
)

What are Claims?

Claims are the "meat" of the JWT. Common registered claims include:

Practical Example

Imagine a user logs into a service. The server validates the credentials and returns a JWT. The payload might look like this:

{
  "sub": "1234567890",
  "name": "John Doe",
  "admin": true,
  "iat": 1516239022
}

The client stores this token (often in LocalStorage or a Cookie) and sends it in the Authorization header using the Bearer schema for subsequent requests. The server simply checks the signature to verify the user's identity without hitting the database for every single request.

Security Best Practices

  1. Do Not Store Sensitive Data: JWTs are encoded, not encrypted. Anyone who intercepts the token can read your payload. Never store passwords, SSNs, or private keys in the payload.
  2. Validate the Algorithm: Always enforce the expected algorithm on the server side to prevent "alg: none" attacks.
  3. Use HTTPS: Always transmit tokens over encrypted connections to prevent man-in-the-middle attacks.
  4. Keep Secrets Secret: If using HMAC, ensure your secret key is long, complex, and stored securely.
  5. Short Expiration: Set a reasonable expiration time to limit the window of opportunity if a token is stolen.

Common Mistakes to Avoid

Frequently Asked Questions

Is JWT the same as OAuth2?

No. OAuth2 is an authorization framework, while JWT is a token format. OAuth2 can use JWTs as access tokens, but it isn't required to.

Can I revoke a JWT?

By design, JWTs are stateless and hard to revoke before they expire. To revoke them, you usually need a "blacklist" or "revocation list" stored in a fast database like Redis.

What is Base64Url encoding?

It is a variation of Base64 that replaces + with -, / with _, and removes the padding = characters to make the string safe for URLs.

Why is my JWT not decoding?

Ensure it has exactly two dots and that it follows the standard format. Sometimes hidden characters or extra spaces can break the decoding process.

Is this tool safe?

Yes. This decoder runs entirely in your browser. We do not transmit your token to any server. You can even use it offline once the page is loaded.