What Is a JWT? How to Decode, Read and Verify a JSON Web Token

Learn how a JSON Web Token is built, what the exp, iat and sub claims mean, why decoding is not verifying, and how to debug expired or rejected tokens safely.

Updated September 29, 2026 6 min read

Use the free JWT DecoderDecode JWT header and payload, check expiry

An API call starts failing with "401 Unauthorized" and the only clue is a long string in the Authorization header that begins with eyJ. A single sign-on integration logs users out after exactly an hour. A backend rejects tokens from a new identity provider with "invalid signature". All of these involve JSON Web Tokens, and all of them become much easier to diagnose once you can look inside the token.

This guide explains how a JWT is structured, what the standard claims mean, the crucial difference between decoding a token and verifying it, how to inspect one without sending it anywhere, and how to track down the most common token errors.

The three parts of a JWT

A JWT (defined in RFC 7519) is three Base64URL-encoded sections joined by dots:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IlNhbXBsZSBVc2VyIiwiaWF0IjoxNzAwMDAwMDAwLCJleHAiOjE3MDAwMDM2MDB9.LTt5FGNkV_DmkYn5_glnOvfjtkfXyMbidsJusYppgjo
  1. Header: JSON describing the token, typically {"alg": "HS256", "typ": "JWT"}. The alg field names the signing algorithm.
  2. Payload: JSON containing the claims, the statements the token makes about the user and itself.
  3. Signature: computed over the first two parts using a secret or private key.

The eyJ prefix appears because {" encoded in Base64 always starts that way. Decoding the payload above gives:

{
  "sub": "1234567890",
  "name": "Sample User",
  "iat": 1700000000,
  "exp": 1700003600
}

Base64URL is encoding, not encryption. Anyone who has the token can read its payload. Never put passwords, secrets or sensitive personal data in a JWT payload.

The claims you will see most

Claim Meaning
iss Issuer: who created the token
sub Subject: usually the user ID
aud Audience: which service the token is meant for
exp Expiration time, as a Unix timestamp in seconds
iat Issued-at time
nbf Not before: the token is invalid until this time
jti A unique token ID, used to prevent reuse

Times are Unix timestamps in seconds. In the example, exp minus iat is 3,600 seconds, so the token lives for one hour. Identity providers add their own claims too, such as email, roles or scopes.

Decoding is not verifying

Decoding means reading the header and payload, which requires no key. Verifying means recomputing the signature with the correct key and checking that it matches, and then checking exp, nbf, iss and aud. Only verification tells you the token is genuine and has not been altered.

This distinction is at the heart of JWT security. A server must never trust a token's contents just because they decode correctly. It must also decide for itself which algorithms it accepts, rather than trusting the alg field in the header; accepting "alg": "none" or letting an attacker switch algorithms are well-known historical vulnerabilities.

There are two families of algorithm:

  • HMAC (HS256, HS384, HS512): one shared secret signs and verifies. Every service that verifies can also create tokens.
  • Asymmetric (RS256, ES256 and others): a private key signs; a public key verifies. Identity providers usually use these and publish their public keys at a JWKS URL.

Decode a token with our tool

The JWT Decoder decodes and optionally verifies tokens in your browser. The token and secret are never sent anywhere, which matters because a valid token is a credential.

  1. Open the JWT Decoder and paste the token into Encoded JWT. A leading Bearer is removed automatically. Load sample creates a signed demo token.
  2. The token is shown split into its three coloured parts, and the Header and Payload appear as formatted JSON, each with a copy button.
  3. Read the status badge: Expired, Not valid yet or Not expired (or No expiry (exp) set), plus badges for alg and typ.
  4. Check the time rows for Expires (exp), Issued at (iat) and Not before (nbf), shown as dates in your local time with a relative description such as "in 45 minutes" or "2 days ago".
  5. To check an HMAC signature, enter the Secret key under Verify signature (HS256 / HS384 / HS512). Tick Secret is Base64 / Base64URL encoded if your secret is stored that way. The result reads Signature verified or Invalid signature for this secret.
  6. Download saves the decoded header and payload as JSON.

Signature checking supports HS256, HS384 and HS512. For RS256, ES256 and other asymmetric tokens, the tool still decodes everything but tells you the algorithm is not supported for verification; verify those in your server's JWT library with the provider's public key. A token with five parts is an encrypted JWE and cannot be read without the decryption key.

Decoding in code

In Node.js, you can read the payload in one line for debugging:

const [, payload] = token.split(".");
JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));

For anything beyond debugging, use a maintained library that verifies signatures and claims, such as jose in JavaScript or PyJWT in Python. Do not write your own verification.

Troubleshooting token errors

"Token expired" soon after login

Compare exp with the current time. Access tokens are often deliberately short-lived, and the client should use a refresh token to obtain a new one. If tokens expire earlier than expected, check the clock on the server: a clock that is a few minutes off makes valid tokens look expired or not yet valid. Many libraries allow a small leeway for this.

"Invalid signature"

The verifier is using the wrong key: a different secret, a rotated key, or a secret that was stored Base64-encoded but used as plain text (or the reverse). For asymmetric tokens, confirm the kid in the header matches a key in the provider's published key set.

"Invalid audience" or "invalid issuer"

The token was issued for a different API or by a different environment, such as a staging identity provider. Compare aud and iss with the values your server expects.

The token will not decode

Check that the whole token was copied, including the last part, and that no quotes or line breaks came with it.

Frequently asked questions

Is it safe to paste a JWT into an online decoder?

Only if the decoder runs locally. A valid token can be used to access the account until it expires. Our decoder runs entirely in your browser; with other sites, use expired or test tokens.

Can someone change the data in my JWT?

They can change it, but the signature will no longer match, and a correctly implemented server will reject it. That is why servers must verify every token.

Is a JWT encrypted?

A standard signed JWT is not; its payload is only encoded and anyone can read it. Encrypted tokens (JWE) exist but have five parts and need a key to read.

Why does my JWT start with eyJ?

Every JWT header is JSON starting with {", and those characters always encode to eyJ in Base64URL.

What does exp mean in a JWT?

It is the expiry time, given as the number of seconds since 1 January 1970 UTC. After that moment, the token must be rejected.

Try it now: JWT Decoder

Loading tool…