What the three dotted segments of a JWT reveal before signature check
A JSON Web Token is one compact string with three pieces separated by dots. The first piece is the header, the second is the payload, and the third is the signature. Each piece uses Base64URL, which is Base64 with URL-safe spelling: minus instead of plus, underscore instead of slash, and padding often omitted. Decode turns header and payload into JSON. The header normally carries typ JWT and alg naming the signing method. The payload carries claims such as sub, exp, and iat. The signature is raw bytes in Base64URL form, not another JSON object.
A JWT is signed, not encrypted. Anyone who holds the string can Base64URL-decode the middle segment and read claim values. Signing proves the issuer had a key and that header and payload were not altered after signing. It does not hide usernames, roles, or internal IDs from people who can copy the token. Confidential fields belong inside encrypted envelopes such as JWE, or they should stay off the wire. The alg field tells you whether verification needs a shared secret or an asymmetric public key.
Symmetric algorithms HS256, HS384, and HS512 use HMAC with a shared secret; see HMAC for how keyed digests differ from bare hashes. RS256 through RS512 sign with RSA PKCS#1 and a matching hash. PS256 through PS512 use RSA-PSS padding. ES256 through ES512 use ECDSA on named curves. Those asymmetric families verify with an SPKI PEM public key as documented on RSA cipher. This page decodes structure, reads claims, and checks signatures when you supply the right key. To build a new signed token, use JWT encoder. Header alg none is not accepted for verification here.
How Base64URL segments, typ and alg, claims, and key material fit together
Why every JWT splits into exactly three Base64URL segments between dot characters
- The signing input is the UTF-8 bytes of header, a dot, and payload, both still in Base64URL form as they appear in the token.
- The third segment is the signature over that input. Missing dots, extra dots, or empty segments break the compact serialization rules from RFC 7519.
- Decode on this page parses the split first. Only after two valid JSON objects appear in header and payload does signature verification become meaningful.
Why header typ and alg must be read before you trust payload claim values
- typ JWT marks the object as a JSON Web Token rather than some other JOSE type your library might accept.
- alg names the algorithm for the third segment. HS family means HMAC. RS and PS mean RSA with different padding. ES means ECDSA with a named curve.
- Libraries should reject a mismatch between alg and the key you provide. Reading alg here tells you whether to paste a shared secret or an SPKI public PEM.
Why exp, iat, and sub claims use NumericDate seconds rather than millisecond timestamps
- exp is seconds since the Unix epoch when the token should stop being accepted, unless your policy ignores it locally.
- iat records issue time in the same second units. nbf can forbid use before a start instant with the same NumericDate shape.
- A millisecond wall clock pasted into exp looks decades in the future when parsers treat it as seconds. Compare claim numbers with a timestamp line in seconds before you blame signature failure.
Why HS256 family secrets and RS PS ES public keys are not interchangeable verify inputs
- HS256, HS384, and HS512 need the same symmetric secret the issuer used. Wrong secret yields a failed verify even when JSON claims look fine.
- RS256, RS384, RS512, PS256, PS384, PS512, ES256, ES384, and ES512 need the issuer matching public key in SPKI PEM form, not the private key and not an HMAC string.
- Choosing verify input from alg avoids treating a PEM block as UTF-8 secret material or vice versa. JWT encoder signs with the private or secret side of the same pairing.
Where decoded JSON looks fine but verification or expiry still disagree
Valid structure and readable claims with a signature that never validates
Header and payload JSON can parse while the third segment still fails against your key. HS family tokens need the exact shared secret bytes the issuer signed with, not a rotated staging secret. RS, PS, and ES tokens need the correct SPKI public PEM, including any certificate chain trimming your issuer documents. Swapping test and production keys is a common cause when sub and exp already look plausible.
An exp claim that appears to expire centuries after the real session ended
RFC 7519 NumericDate counts seconds, not milliseconds. Pasting a thirteen-digit millisecond clock into exp makes parsers think the token stays valid for an absurd horizon. iat and nbf follow the same unit rule. Cross-check the numeric claim against civil time on the timestamp tool in seconds before you assume the signing key is wrong.
A token whose header advertises alg none or ships without a third segment
Unsigned tokens may still decode for debugging, but they carry no integrity proof. Production APIs should reject alg none outright. This page treats alg none as unsupported for verify and warns when the signature segment is absent. For a legitimately signed replacement, issue a new token on JWT encoder with a supported alg and a real secret or key pair.