# How to decode a JWT and check when it expires

> Read a JSON Web Token's header and payload, understand Base64URL and the exp claim, and learn why decoding a token is not the same as verifying it.

- URL: https://www.tooljig.com/blog/how-to-decode-a-jwt
- Category: Developer
- Published: 2026-11-23

A JSON Web Token (JWT) looks like a long random string, but most of it is readable JSON that has only been encoded, not encrypted. Decoding it shows who the token was issued to, what it allows and when it expires, which is usually what you need when a request fails with a 401. This guide shows how to decode a token safely, how to read the time claims, and why a decoded token proves nothing on its own.

> Tool: [JWT Decoder](https://www.tooljig.com/jwt-decoder): Decode a JSON Web Token to read its header, payload and expiry. Decoding happens in your browser and the token is never sent anywhere.

## Step by step

1. Copy the token from wherever you found it: an `Authorization` header, a cookie, or your browser's developer tools. A leading `Bearer ` is fine; the decoder ignores it.
2. Paste it into the [JWT decoder](https://www.tooljig.com/jwt-decoder).
3. Read the **Header**, which names the signing algorithm, and the **Payload**, which holds the claims, both pretty-printed as JSON.
4. Check the time claims. If the payload contains `iat`, `nbf` or `exp`, the decoder shows them as readable dates under **Issued at**, **Not before** and **Expires**.
5. Look at the status badge. It says **Expired** or **Not expired** by comparing `exp` with your device's clock.
6. Use **Copy payload** if you need the claims elsewhere, for example to paste into a bug report with sensitive values removed.

The token is decoded in your browser and never sent anywhere.

## What is inside a JWT

A signed JWT (formally a JWS, defined in RFC 7515 and RFC 7519) has three parts separated by dots:

```text
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyXzEyMyIsIm5hbWUiOiJBZGEgTG92ZWxhY2UiLCJyb2xlIjoiYWRtaW4iLCJpYXQiOjE3NjM4NTYwMDAsImV4cCI6MTc2Mzg1OTYwMH0.Xr96FggIgIX3o3Gtgk8Mwxd5fCZX3nm4SE0OuxpMgoc
```

The first part is the **header**:

```json
{ "alg": "HS256", "typ": "JWT" }
```

The second is the **payload**, a set of claims:

```json
{
  "sub": "user_123",
  "name": "Ada Lovelace",
  "role": "admin",
  "iat": 1763856000,
  "exp": 1763859600
}
```

The third is the **signature**: bytes computed from the first two parts and a key. It is not JSON and cannot be "decoded" into anything meaningful; it can only be checked with the right key.

Each part is Base64URL encoded. Base64URL is ordinary Base64 with `-` instead of `+`, `_` instead of `/`, and the trailing `=` padding removed, so the result is safe in URLs and headers. You can decode a single segment yourself with the [Base64 decoder](https://www.tooljig.com/base64-encode-decode), which accepts the URL-safe alphabet with or without padding. Because the header always starts with `{"`, almost every JWT begins with `eyJ`, which is a handy way to recognise one in a log.

## Reading the time claims

RFC 7519 defines a set of registered claims. The ones you will check most often:

| Claim | Name | Meaning |
| --- | --- | --- |
| `iss` | Issuer | Who created the token |
| `sub` | Subject | Who the token is about, usually a user ID |
| `aud` | Audience | Which service the token is for |
| `exp` | Expiration time | The token must not be accepted on or after this time |
| `nbf` | Not before | The token must not be accepted before this time |
| `iat` | Issued at | When the token was created |
| `jti` | JWT ID | A unique ID, often used to revoke a single token |

Time claims are NumericDate values: seconds since 1 January 1970 UTC, not milliseconds. In the example, `iat` is 1763856000 (2025-11-23 00:00:00 UTC) and `exp` is 1763859600, exactly one hour later. If you need to convert one by hand, the [Unix timestamp converter](https://www.tooljig.com/unix-timestamp-converter) does it.

When an API rejects a token that "should" work, check in this order:

1. Is `exp` in the past? Then the client needs to refresh the token.
2. Is `nbf` in the future? Then the token was issued for later, or one machine's clock is wrong.
3. Does `aud` match the service you are calling, and `iss` the identity provider it trusts?
4. Are the claims the API needs, such as a role or scope, actually present?

> **Note:** The expiry badge uses your device's clock. Servers often allow a small leeway, typically a few seconds to a few minutes, for clock skew, so a token that has just expired here may still be accepted for a short time, and the reverse is also possible if your clock is ahead.

## Decoding is not verifying

Anyone can create a token with any payload. Editing `"role": "user"` to `"role": "admin"` and re-encoding the payload takes seconds. What stops this from working is the signature: the server recomputes it with its secret (for HMAC algorithms such as HS256) or checks it with the issuer's public key (for RS256, ES256 and similar), and rejects the token if it does not match.

The decoder deliberately does not verify signatures. Verification needs the key, and the key belongs on your server. So a decoded payload tells you what a token **claims**, not whether those claims are true. Rules that follow from this:

- Never make an authorization decision from a decoded but unverified token, in the browser or anywhere else.
- On the server, use a maintained JWT library, pass it the expected algorithm explicitly, and reject `alg: none`. Accepting whatever algorithm the header names has led to real vulnerabilities.
- Validate `exp`, `nbf`, `iss` and `aud` as well as the signature.

Also remember that a signed JWT is not encrypted. Anything in the payload is readable by whoever holds the token, so do not put passwords, personal data you would not show the user, or internal secrets in claims. Tokens that are encrypted (JWE) have five parts instead of three and cannot be read without the key; the decoder shows an error for them instead of a payload.

## Handling tokens safely

A valid access token is a credential: whoever has it can act as the user until it expires. Treat it like a password.

- Prefer tokens from development or staging environments when debugging, or tokens that have already expired.
- Do not paste production tokens or signing secrets into websites you do not control. Many online decoders send what you paste to a server. Tooljig decodes locally, but the safest habit is not to share live credentials with any site.
- Never put a signing secret into an online tool to "verify" a token. If the secret leaks, anyone can mint valid tokens.
- When sharing a decoded payload in a ticket, remove the signature and any personal data.

If a production token does leak, revoke it or rotate the signing key rather than waiting for it to expire. To generate a strong random secret for a development setup, the [password generator](https://www.tooljig.com/password-generator) uses the browser's cryptographic random number generator.

## FAQ

### Can I decode a JWT without the secret?

Yes. The header and payload are only Base64URL-encoded JSON, so anyone can read them. The secret or public key is needed only to verify the signature, which proves the token was issued by someone holding the key and has not been changed.

### Why does the decoder say my token is expired when the API still accepts it?

Either your device's clock differs from the server's, or the server allows some leeway after `exp`. Compare the **Expires** time with the current UTC time, and check the server's JWT library settings for a clock-skew tolerance.

### Is the payload of a JWT encrypted?

No. A standard signed JWT is encoded, not encrypted, and the payload is readable by anyone who has the token. Only JWE tokens are encrypted. Keep secrets and sensitive personal data out of JWT claims.
