ByteTips.

Guide

How JWT Works: Header, Payload, Signature

A JWT is three Base64 strings separated by dots: a header, a payload of claims, and a signature. The signature proves who issued it — the encoding proves nothing.

October 19, 2026 · 6 min read · Shayan · JWT & Security

🛠️ Try it in your browser — no uploads

Skip the manual work and run this on your own input with the free JWT Decoder.

Open free JWT Decoder on Byte-Kit →

Short answer: a JWT (JSON Web Token) is three base64url-encoded parts joined by dots — header.payload.signature. The header names the signing algorithm, the payload carries claims (who you are, when the token expires), and the signature is a cryptographic checksum over the first two parts made with the issuer's secret or private key. Anyone can read the payload — it is only encoded, not encrypted. Only someone with the key can produce a valid signature, and that asymmetry is the entire security model.

The three parts

A token looks like this: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c. Split on the dots and base64url-decode the first two parts and you get plain JSON. The third part is opaque bytes — the signature.

Part 1: the header

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

The header is small on purpose: it says which algorithm signed the token (alg — HS256, RS256, ES256 are the common ones) and that this is a JWT (typ). Some tokens also carry kid, a key ID telling the verifier which of several keys to check against — useful when keys rotate. The header is not trusted on its own: a verifier must check that alg is one it expects, because accepting an attacker-chosen algorithm is exactly how the old alg:none attacks worked (more on that below).

Part 2: the payload and its claims

{
  "sub": "1234567890",
  "name": "John Doe",
  "iat": 1516239022,
  "exp": 1516242622,
  "iss": "https://auth.example.com",
  "aud": "my-api"
}

The payload is a set of claims — name/value assertions about the subject. The JWT standard (RFC 7519) defines seven registered claims: iss (issuer), sub (subject — usually the user ID), aud (audience — who the token is for), exp (expiry, seconds since epoch), nbf (not-before), iat (issued-at), and jti (a unique token ID, handy for revocation lists). Everything else is a public or private claim — name, email, roles, permissions — namespaced by convention to avoid collisions. Keep payloads small: the whole token rides in an HTTP header on every request.

Part 3: the signature

The signature is computed over the exact text of the first two parts: signature = SIGN(base64url(header) + "." + base64url(payload), key). With HS256 the key is a shared secret and both sides use HMAC-SHA256; with RS256 the issuer signs with its RSA private key and anyone verifies with the public key. Verification is just recomputation: the verifier re-signs the header and payload it received and compares the result with the signature on the token. Any change to even one character — a flipped claim, a swapped algorithm — produces a different signature and the token is rejected.

Signed is not encrypted

This is the misunderstanding that causes real incidents. Base64url is an encoding, not encryption: the payload is readable by anyone who holds the token — paste it into any decoder and the claims are right there. The signature guarantees integrity and authenticity, not confidentiality. Never put passwords, SSNs, or anything sensitive in a payload. If the claims must be secret, that is a different token type (JWE, JSON Web Encryption) — a standard JWT is a signed postcard, not a sealed envelope.

The alg:none trap

The classic JWT attack exploits verifiers that trust the header's alg field. An attacker takes a valid token, changes alg to "none", strips the signature, and edits the payload — say, promoting themselves to admin. A verifier that honors the header's algorithm choice accepts the unsigned token as genuine. The fix is on the verifier side and it is absolute: hardcode the expected algorithm, reject anything else, and reject unsigned tokens outright. Modern libraries do this by default; hand-rolled verification often does not.

Quick answers

  • Can I decode a JWT without the secret? Yes — decoding needs no key, because the payload is only encoded. But decoding is not verifying: reading the claims tells you what the token says, only signature verification tells you whether to believe it.
  • How long should a token live? Access tokens: minutes to an hour. Long-lived tokens are a liability if leaked — pair a short access token with a refresh token instead of stretching exp.
  • HS256 or RS256? HS256 with a shared secret is fine when one service both issues and verifies. RS256 fits microservices: the auth server holds the private key, every service verifies with the public key, and no service can mint tokens.
  • Where do I store it? Not in localStorage if XSS is a threat model — any script on the page can read it. HttpOnly cookies are the safer default for browser apps.

Try it

Paste a token into the JWT Decoder to see the header, payload, and claims decoded in your browser — nothing uploaded, which matters when the token belongs to a real user. Then read How to Check If a JWT Is Expired (the exp Claim) for the expiry check and the seconds-vs-milliseconds trap.

Written by Shayan — Creator of Byte-Kit & ByteTips. Building private developer tools.

More JWT & Security guides