How to check a JWT's expiration by hand
Learn to read the exp claim in a JSON Web Token. Turn it into a date and compare it with the current time. No coding needed.
Published By Muhammad Sohail
Short answer
Read the exp claim in the token's payload. It is a count of seconds since 1 January 1970 UTC. Convert it to a date and compare it with the current time: if now is equal to or later than exp, the token has expired. This checks the time only, not the signature.
- Difficulty
- Beginner
- Steps last verified
- Software
- Google Chrome 158.0.8127.37 (64-bit)
- Python 3.11.9
- PyJWT 2.15.1
- Windows 10 (AMD64)
- Prerequisites
- A JWT you are allowed to inspect (this tutorial uses two sample tokens)
- A web browser
Many websites and apps keep you signed in with a small piece of text called a token. A common kind is the JSON Web Token, or JWT. When a request fails with “token expired”, or a login stops working after an hour, the first question is simple: has this token really expired, and when?
You can answer that yourself in a few minutes. A JWT carries its own expiry time inside it, written as a number. In this tutorial I read that number, turn it into a normal date, and compare it with the current time. I did every step with two sample tokens I made for this tutorial: one that was still valid and one that had already expired. Every value below comes from that run on 27 November 2026, in Pakistan (UTC+5).
You do not need to write code. One optional section near the end has a short code snippet; you can skip it and still follow everything else.
What exp, iat and nbf mean
A JWT is a short piece of text made of three parts joined by dots: a header, a payload and a signature. The header says how the token was signed. The payload holds the information, called claims. The signature lets a server check that nobody changed the token. This three part form is defined in RFC 7515, the JSON Web Signature standard. An RFC is a numbered document that defines an internet standard.
The header and payload are JSON, a plain text format of names and values, such as "name": "Sample User". Before they go into the token they are encoded with Base64URL. Encoding means rewriting the text with a limited set of letters, digits and two symbols so it travels safely inside a web address. It is not encryption: anyone who has the token can turn it back into readable text.
Three claims in the payload are about time. RFC 7519, the JWT standard, defines them:
exp(expiration time): the moment the token stops being valid.iat(issued at): the moment the token was made.nbf(not before): the moment the token starts being valid.
All three are optional, so a token may have none of them. Their values use a format the standard calls NumericDate: the number of seconds since 1 January 1970 at midnight UTC. UTC is the world reference time that does not change with seasons; Pakistan is 5 hours ahead of it. This seconds count is also called Unix time, and today it is a 10 digit number such as 1795782718.
The rule for expiry is strict. RFC 7519 says the current time must be before exp for the token to be accepted. So a token has expired when the current time is equal to or later than exp.
Step 1: Decode the token
Decoding turns the encoded parts back into readable JSON. Paste the whole token into the JWT Decoder, which reads the token in your browser without uploading it, and select Decode. The token never leaves your device, which matters when it belongs to a real account.
Here is what the decoder showed for my valid sample token, decoded at 4:35 PM my time:
- Expires (exp): Friday, November 27, 2026 at 5:31:58 PM GMT+5, and below it 2026-11-27 12:31:58.000 UTC
- Status: Valid for 56 more minutes, as of 4:35 PM
- Issued at (iat) and Not before (nbf): both 4:31:58 PM GMT+5, which is 11:31:58 UTC
The decoder shows each time twice: in your own time zone and in UTC. Look at both. If you compare a UTC time with your local clock by mistake, you will be off by your UTC offset, which is 5 hours in my case.
The Claims list shows dates, not the raw numbers. To see the numbers, scroll to the Payload block. For the valid sample token it held:
{
"sub": "sample-user-123",
"name": "Sample User",
"iat": 1795779118,
"nbf": 1795779118,
"exp": 1795782718
}You do not need to run anything here; this is only what the payload looks like. exp minus iat is 3,600 seconds, so this token was made to last exactly one hour.
Then I decoded the expired sample token at 4:40 PM. Its exp was 4:21:58 PM GMT+5 (11:21:58 UTC), and the status read Expired 18 minutes ago.
Two notes appear with every decoded token, and they matter. The first says JWT payloads are only encoded, not encrypted, and that the tool does not verify the signature. The second says: “Signature not verified. This tool only decodes the token.” The status line tells you about time only. It does not tell you the token is genuine.
Step 2: Turn exp into a date yourself
The decoder already converts the times, but it helps to check one by hand once, so you know what the number means. Copy the exp number from the Payload block and paste it into the Unix Timestamp Converter, which turns Unix time into a date in any time zone. Make sure the Time zone menu shows your own zone.
For the valid sample token’s exp, 1795782718, the converter showed:
- Detected: seconds
- UTC: 2026-11-27 12:31:58 UTC
- Asia/Karachi (UTC+05:00): Friday, November 27, 2026 at 5:31:58 PM GMT+5
- Relative: in 1 hour
The dates match the decoder exactly. The “Detected: seconds” line is worth a look: JWT times are always in seconds. If a token holds a 13 digit number, it was probably written in milliseconds by mistake, and it will read as a date thousands of years away.
The Relative row rounds
When I made that conversion, the converter’s Current Unix time was 1795779957. The token had 2,761 seconds left, which is about 46 minutes, yet the Relative row said “in 1 hour”. It rounds to the nearest unit, and from 45 minutes up it shows hours. For the expired token, about 54 minutes after exp, it said “1 hour ago”. Use the Relative row as a rough guide, and compare the exact numbers when it matters.
Step 3: Compare exp with the current time
This is the actual check, and it needs no conversion at all. The converter shows the current Unix time at the top of the page, in seconds. Compare it with exp:
- If the current time is smaller than
exp, the token has not expired yet. The difference is the number of seconds left. - If the current time is equal to or larger than
exp, the token has expired.
Here are my two sample tokens side by side, with the current time the converter showed when I checked each one:
| Valid sample token | Expired sample token | |
|---|---|---|
iat (issued at) |
1795779118 (11:31:58 UTC) | 1795775518 (10:31:58 UTC) |
exp (expires) |
1795782718 (12:31:58 UTC) | 1795778518 (11:21:58 UTC) |
Lifetime, exp minus iat |
3,600 seconds (1 hour) | 3,000 seconds (50 minutes) |
| Current time when checked | 1795779957 | 1795781750 |
Current time minus exp |
minus 2,761 seconds | plus 3,232 seconds |
| Result | Not expired | Expired |
What this means: for the valid sample token the current time was 2,761 seconds before exp, so it still had about 46 minutes left. For the expired one, the current time was 3,232 seconds past exp, about 54 minutes, so it had expired.
Why UTC makes this easy
Unix time is the same number everywhere in the world at the same moment. My exp of 1795782718 is 12:31:58 in London and 5:31:58 PM in Karachi, but it is one moment. Comparing two Unix numbers avoids time zone mistakes completely. Time zones only matter when you turn the number into a date for people to read.
nbf: a token that is not valid yet
If a token has nbf, it is also rejected before that moment. In both of my sample tokens nbf was equal to iat, so this did not come up. When nbf is in the future, the JWT Decoder says “Not valid yet” and how long until it becomes valid.
Optional: decode the payload by hand
You do not need this section. It shows that there is no magic in the decoder: the payload is ordinary Base64URL text.
Copy only the middle part of the token, between the first and the second dot, without the dots. Paste it into the Base64 Encoder and Decoder, which also reads the URL-safe Base64 that JWTs use, choose Decode, and select Decode from Base64. For my valid sample token, the result was the same payload as above on one line, 97 bytes of text:
{"sub":"sample-user-123","name":"Sample User","iat":1795779118,"nbf":1795779118,"exp":1795782718}You do not need to run this; it is the output I got.
The Base64 tool accepts URL-safe Base64 without padding, so you do not need to change anything. If you paste the whole token instead, it stops with “Invalid character ‘.’ at position 37”. The dot is not part of Base64; it only separates the three parts. Position 37 is the first dot, right after the 36 characters of the header.
Optional: check it with code
This part is for readers who use the browser’s developer tools. These are built into the browser: press F12 to open them, then choose the Console tab, where you can type JavaScript, the language web pages run. If you do not code, skip this section.
The snippet below does the same three steps as above. First it takes the middle part of the token and turns it back into standard Base64: - becomes +, _ becomes /, and the = padding at the end is added back. Then it decodes the bytes as UTF-8, the usual way of storing text as bytes, and reads the JSON. Last, it compares exp with the current time in seconds. Replace PASTE_TOKEN_HERE with your token before you run it. Chrome may ask you to type allow pasting first.
{
const token = 'PASTE_TOKEN_HERE';
const base64 = token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');
const padded = base64 + '='.repeat((4 - (base64.length % 4)) % 4);
const bytes = Uint8Array.from(atob(padded), (c) => c.charCodeAt(0));
const payload = JSON.parse(new TextDecoder().decode(bytes));
const now = Math.floor(Date.now() / 1000);
console.log({ exp: payload.exp, now, secondsLeft: payload.exp - now, expired: now >= payload.exp, expUtc: new Date(payload.exp * 1000).toISOString() });
}The outer braces let you run it a second time without reloading the page. It only reads the token. It does not check the signature.
For my two sample tokens it printed:
| Valid sample token | Expired sample token | |
|---|---|---|
exp |
1795782718 | 1795778518 |
now |
1795781030 | 1795781152 |
secondsLeft |
1688 | minus 2634 |
expired |
false | true |
expUtc |
2026-11-27T12:31:58.000Z | 2026-11-27T11:21:58.000Z |
What this means: the snippet agreed with the decoder and the converter. The valid sample token had 1,688 seconds left (about 28 minutes) when I ran it, and the expired one was 2,634 seconds past exp (about 44 minutes).
How the sample tokens were made
I made both sample tokens with a short Python script using PyJWT, a Python library for creating and checking JWTs. It signed them with HS256 and a throwaway secret that is used for nothing else. The valid sample token was issued at the moment the script ran and set to expire one hour later. The expired one was issued one hour earlier and expired 10 minutes before the run.
The script also asked PyJWT to check both tokens properly, which means checking the signature with the secret as well as the time. PyJWT accepted the valid sample token and rejected the expired one with ExpiredSignatureError (“Signature has expired”). That is what real verification looks like: a library with the key, on the server, not a decoder in the browser.
What the expiry time does not tell you
An exp in the future does not make a token trustworthy. A server checks much more before it accepts a token. RFC 7519 section 7.2 describes how to validate a JWT, including its signature, and servers usually check these things too:
- The signature. Anyone can write a payload with a future
exp. Only the signature, checked with the right key, shows that the issuer really made the token. Decoding does not check it. - Who issued it and who it is for. Servers usually check the issuer and the audience claims as well.
- Whether it was cancelled. A server can refuse a token before its
exp, for example after you sign out. - Clock differences. The status in the decoder comes from your device’s clock at the moment you decode. If your clock is wrong, the status is wrong. Servers also have their own clocks. RFC 7519 lets implementers allow “some small leeway, usually no more than a few minutes” for this, so a server may still accept a token just after its
exp.
A token with no exp at all is not an error in the standard, but it never expires by itself. The JWT Decoder shows a warning when exp is missing.
Troubleshooting
The token has no exp claim. The decoder says “No expiry”. The token’s lifetime is then decided only by the server, if at all.
The date is thousands of years away. The value is probably in milliseconds instead of seconds. JWT times must be seconds. The decoder warns that it “looks like milliseconds”.
The decoder says valid, but the server says expired. Compare your device clock with the real time, and remember the server may use its own clock without leeway. Also check that you decoded the same token the server received.
The Base64 tool says “Invalid character ‘.’”. You pasted the whole token. Copy only the part between the first two dots.
What to remember
expis a count of seconds since 1 January 1970 UTC. A token has expired when the current time is equal to or later thanexp.- Comparing two Unix numbers avoids time zone mistakes. Convert to a date only to read it.
- The decoder shows each time in your time zone and in UTC; the status uses your device’s clock.
- Decoding is not verifying. A future
expsays nothing about whether the token is genuine; only the signature, checked with the key, does that.
Sources
- RFC 7519: JSON Web Token (JWT)
www.rfc-editor.org
- RFC 7515: JSON Web Signature (JWS)
www.rfc-editor.org
- MDN: Window.atob()
developer.mozilla.org
- MDN: TextDecoder
developer.mozilla.org
- MDN: Date.now()
developer.mozilla.org
- PyJWT documentation
pyjwt.readthedocs.io
Tools used in this guide
- JWT Decoder
Decode JSON Web Tokens in your browser: header, payload, and claims with expiry times, plus warnings for risky tokens.
- Unix Timestamp Converter
Convert Unix timestamps in seconds, milliseconds, microseconds, or nanoseconds to dates in any time zone, and back.
- Base64 Encoder and Decoder
Encode text or any file to Base64 and decode it back, with full UTF-8 support, URL-safe output, and data URIs.