Free online tool

Upload a file

Drop your file hereTap to choose a file

or click to browse, or paste from the clipboard

← Back to Blog

How to Check If a JWT Is Expired: exp, nbf, iat and Clock Skew

A JWT is expired when the current Unix time, counted in seconds, is equal to or later than its exp claim. To check JWT expiration, decode the middle part of the token, read exp and compare it with the clock in seconds, not milliseconds: in JavaScript, Math.floor(Date.now() / 1000) >= exp. Paste a token into the JWT Expiry Checker to see the answer with a live countdown, every date in UTC and your time zone, and your server's leeway applied.

How to check JWT expiration with Zutilium

  1. Open the JWT Expiry Checker. It loads a sample token first; paste yours into the JSON Web Token box to replace it. A Bearer prefix, quotes and line breaks are ignored.
  2. Read the status: Valid now, Expired, Not valid yet or No expiry, with a countdown to exp, or the time since it passed, that updates every second.
  3. Under Clock skew leeway, choose the margin your server allows: None, 30 s, 60 s, 5 min or Custom (0 to 86,400 seconds).
  4. To test another moment, such as when a request failed in your logs, choose Another time under Check the token at and enter it in your own time zone.
  5. Read the Dates cards (exp, nbf, iat and auth_time in UTC, your time zone and relative time) and any warnings under Checks.
  6. Optionally, paste the secret or the issuer's public key under Verify the signature. For HMAC tokens, set Secret format to Text or Base64 or base64url to match how your server reads the secret.

The status reflects the dates alone. The badge beside it reads Signature not checked until a key proves the token genuine, and a server can still reject a token for its issuer, audience or revocation. Everything runs in your browser, so the token and key are not uploaded or saved.

What the JWT exp, nbf and iat claims mean

RFC 7519 defines all three as a NumericDate: a JSON number of seconds since 1970-01-01T00:00:00Z, ignoring leap seconds. Fractions are allowed but rare. All three claims are optional, so a token without exp never expires by itself.

Claim Name What a verifier does
exp Expiration time Rejects it from the second the clock reaches exp
nbf Not before Rejects it while the clock is earlier than nbf
iat Issued at Nothing required by RFC 7519 (PyJWT rejects one in the future); exp minus iat is the lifetime

The current time must be before exp, so a token with exp 1794823200 (2026-11-16 10:00:00 UTC) works at 09:59:59 and is expired at exactly 10:00:00. Libraries such as jsonwebtoken and jose read the clock in whole seconds, and the checker does the same.

How to decode a JWT

A signed JWT has three parts separated by dots: header.payload.signature. Each part is base64url-encoded, the Base64 variant that uses - and _ instead of + and / and drops the = padding (RFC 7515). The header and payload are JSON objects, which is why most tokens start with eyJ: that is how {" followed by a letter encodes. Decoding needs no key.

This HS256 token was made for this guide. It expired on 16 November 2026 and is signed with the made-up secret example-secret-for-docs-only-0123456789:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2F1dGguZXhhbXBsZS5jb20iLCJzdWIiOiJ1c2VyXzEwMjQiLCJhdWQiOiJhcGkuZXhhbXBsZS5jb20iLCJpYXQiOjE3OTQ4MTk2MDAsIm5iZiI6MTc5NDgxOTYwMCwiZXhwIjoxNzk0ODIzMjAwfQ.JfdUcmdVaZj-oa8b04vwqW7xa2VTtr3INN_M3-tNLZc

Its first two parts decode to:

{"alg":"HS256","typ":"JWT"}
{"iss":"https://auth.example.com","sub":"user_1024","aud":"api.example.com","iat":1794819600,"nbf":1794819600,"exp":1794823200}

The third part is the 32-byte HMAC-SHA256 signature, which is binary rather than JSON. The lifetime is exp minus iat: 1794823200 − 1794819600 = 3,600 seconds, or one hour.

To read a part without code, choose Base64URL under Alphabet in the Base64 Encoder & Decoder and decode it, then paste a date such as exp into the Unix Timestamp Converter. The guide to how Base64 and base64url work explains the padding rules. A token with five parts is encrypted (JWE), so only its header can be read without the recipient's key.

Check expiry in JavaScript, Python, Java, C# or the shell

These snippets decode without verifying: fine for deciding when a client should refresh or for debugging, but a server must verify the signature first.

JavaScript, for browsers and Node.js 16 or later:

function decodeJwtPart(part) {
  const base64 = part.replace(/-/g, '+').replace(/_/g, '/');
  const bytes = Uint8Array.from(atob(base64), c => c.charCodeAt(0));
  return JSON.parse(new TextDecoder().decode(bytes));
}

function jwtStatus(token, leewaySeconds = 0) {
  const { exp, nbf } = decodeJwtPart(token.split('.')[1]);
  const now = Math.floor(Date.now() / 1000); // seconds, not milliseconds
  if (nbf !== undefined && now < nbf - leewaySeconds) return 'not valid yet';
  if (exp !== undefined && now >= exp + leewaySeconds) return 'expired';
  return exp === undefined ? 'no expiry' : 'valid';
}

jwtStatus(token); // 'expired' for the example token

Python, standard library only:

import base64, json, time

def jwt_claims(token):
    part = token.split(".")[1]
    part += "=" * (-len(part) % 4)  # put back the padding base64url leaves out
    return json.loads(base64.urlsafe_b64decode(part))

claims = jwt_claims(token)
print(time.time() >= claims["exp"])  # True: expired

Java, with auth0's java-jwt. JWT.decode reads the token without verifying it, and getExpiresAt() returns null when there is no exp:

Date exp = JWT.decode(token).getExpiresAt();
boolean expired = exp != null && !exp.after(new Date());

C#, with System.IdentityModel.Tokens.Jwt, whose ReadJwtToken does not validate the token either:

bool expired = new JwtSecurityTokenHandler().ReadJwtToken(token).ValidTo <= DateTime.UtcNow;

ValidTo is DateTime.MinValue when exp is missing, so a token without exp reads as expired.

Shell, with jq 1.6 or later (the version that added @base64d):

jq -R 'split(".")[1] | gsub("-";"+") | gsub("_";"/") | @base64d | fromjson
  | {exp: (.exp | todate), expired: (now >= .exp)}' <<< "$TOKEN"

For the example token this prints "exp": "2026-11-16T10:00:00Z" and "expired": true. Without the two gsub calls, jq rejects any part that contains - or _ as invalid Base64. The common cut -d. -f2 | base64 -d pipe fails more quietly on macOS: it drops the last characters of an unpadded part, so the JSON loses its closing brace.

Clock skew and leeway, second by second

Server clocks drift, so RFC 7519 lets verifiers allow a small leeway, usually no more than a few minutes. With a leeway, a token is accepted from nbf minus the leeway until exp plus the leeway. For the example token (nbf 09:00:00, exp 10:00:00 UTC on 16 November 2026), the checker, jsonwebtoken 9.0.3 and PyJWT 2.10.1 give the same answers:

Time (UTC) No leeway 30 s leeway
08:59:59 Not valid yet Valid
09:59:59 Valid Valid
10:00:00 Expired Valid
10:00:29 Expired Valid
10:00:30 Expired Expired

PyJWT blames iat rather than nbf at 08:59:59. To reproduce a row in the checker, choose Another time and enter the UTC time converted to your zone: 10:00:00 UTC is 05:00:00 in New York. With 30 s selected, it reads Valid now and "exp passed just now", with 30 seconds of leeway left.

Defaults differ between libraries, so set Clock skew leeway to what your verifier uses. As of November 2026:

Library Default leeway Setting Error once exp has passed
jsonwebtoken (Node.js) None clockTolerance TokenExpiredError: jwt expired
jose (JavaScript) None clockTolerance JWTExpired (ERR_JWT_EXPIRED)
PyJWT (Python) None leeway ExpiredSignatureError: Signature has expired
Spring Security (Java) 60 s clockSkew (JwtTimestampValidator) Jwt expired at …
Microsoft.IdentityModel (.NET) 5 min ClockSkew IDX10223: … The token is expired.

Keep leeway small, because it extends stolen tokens too. If tokens fail by more than a minute, fix the clocks with NTP instead.

Verify the signature, not just the date

Anyone can write a token with any exp, so decoding shows only what a token claims. Before a server acts on a claim, it must check the signature with the issuer's secret or public key and accept only the algorithms it expects. RFC 8725 requires libraries to support that allow-list, because attackers can switch alg to none or get a server to use its RSA public key as an HMAC secret. With jsonwebtoken, one call checks the signature, exp and nbf:

const jwt = require('jsonwebtoken');

try {
  const claims = jwt.verify(token, secret, { algorithms: ['HS256'], clockTolerance: 30 });
} catch (err) {
  if (err.name === 'TokenExpiredError') console.log('Expired at', err.expiredAt.toISOString());
}
// Expired at 2026-11-16T10:00:00.000Z

PyJWT's jwt.decode() works the same way but also checks aud, so pass audience when the token has one. Without code, paste the key under Verify the signature in the checker. It handles HS256 to HS512, RS256 to RS512, PS256 to PS512, ES256 to ES512 and EdDSA (Ed25519 where the browser supports it), and reads PEM keys, certificates, JWKs and JWK Sets, picking the key by kid. With the secret above, the example token shows "Signature verified with this secret (HS256)."

If the checker warns that a token verifies with a secret published in tutorials, anyone can forge tokens your server accepts. Replace it with at least 32 random bytes (256 bits); a 64-character password from the Password & Passphrase Generator has well over that.

Keep live tokens out of untrusted sites

Most JWT access tokens are bearer tokens, which RFC 6750 defines as tokens that any party holding them can use. Until it expires, a live token pasted into a site that logs or forwards it is as good as your session.

  • Use a decoder that runs on your device. The JWT Expiry Checker decodes and verifies with JavaScript and Web Crypto in your browser and sends nothing over the network.
  • Prefer expired tokens or tokens from a test environment. To ask for help, share the decoded header and payload instead of the token: without the signature, nobody can replay it.
  • Keep tokens out of tickets, chat, screenshots and logs.
  • Never paste a private key into a web page. Verification needs only the public key, and the checker refuses private keys.
  • The payload is only encoded, so anyone with the token can read it. Keep secrets and unneeded personal data out of claims; the checker flags both.

Fix a "jwt expired" error and other expiry problems

"jwt expired", TokenExpiredError or "Signature has expired"

The verifier's clock has passed exp plus any leeway. If it passed hours or days ago, the client is reusing an old token: request a new one, usually with a refresh token, when the API answers 401. A JWT cannot be extended: changing exp breaks the signature, so only the issuer can sign a replacement. Never switch the check off with ignoreExpiration: true (jsonwebtoken) or verify_exp: False (PyJWT) in production.

A new token is rejected straight away

Compare exp with iat on the checker's Dates cards. If they are equal or seconds apart, the lifetime is wrong: in jsonwebtoken, expiresIn: "60" (a string without a unit) means 60 milliseconds, so exp equals iat and the token is born expired. Use the number 60 or a string with a unit, such as "60s" or "1h". If the lifetime looks right, the issuer's and verifier's clocks disagree.

The token never expires

A 13-digit exp is in milliseconds. Read as seconds, 1794823200000 falls in the year 58,845, so libraries accept the token practically forever; the checker flags it and shows the intended date, 2026-11-16 10:00:00 UTC. Create exp with Math.floor(Date.now() / 1000) + 3600, not Date.now() + 3600000. The guide to converting a Unix timestamp to a date covers the units in depth. A No expiry status means exp is missing: add it, or cap the token's age with jsonwebtoken's maxAge or jose's maxTokenAge.

Not valid yet, or iat in the future

The issuer's clock is ahead, so a token used right after issue has an nbf or iat a few seconds in the future. PyJWT reports a future iat as "The token is not yet valid (iat)". Sync both clocks with NTP; a 30 or 60 second leeway covers what drift remains.

The token will not decode, or shows Invalid exp

Two parts mean the signature is missing, five mean an encrypted JWE, and no dots at all mean an opaque token that only its issuer can look up. A +, / or = inside the token means it was converted to standard Base64 somewhere. An exp written as a string, such as "2026-11-16T10:00:00Z", shows Invalid exp, and jsonwebtoken rejects it with "invalid exp value": write the number 1794823200 instead.

Frequently asked questions

How do I check if a JWT is expired in JavaScript?

Split the token on the dots, base64url-decode the second part and parse it as JSON. The token is expired when Math.floor(Date.now() / 1000) is greater than or equal to exp. Comparing Date.now() with exp directly makes every token look expired, because Date.now() counts milliseconds.

Can you check JWT expiration without the secret key?

Yes. exp sits in the payload, which anyone holding the token can decode without a key. The secret or public key only proves that the token is genuine and that nobody changed exp, so clients often read exp to refresh early while servers always verify.

Is the JWT exp claim in UTC or local time?

It counts seconds since 1970-01-01T00:00:00Z (UTC), so the same number names the same instant in every time zone. Zones matter only when you display it. The checker shows 1794823200 as 2026-11-16 10:00:00 UTC and, in New York, 05:00:00 EST.

How long should a JWT be valid?

Short lifetimes limit the damage from a stolen token, because it works until it expires. RFC 6750 recommends bearer tokens that last one hour or less; refresh tokens can keep users signed in for longer. The checker warns when a token lasts more than seven days.