Come funziona
A JWT has the form header.payload.signature, where the first two segments are Base64URL-encoded JSON. The header declares the signing algorithm in alg and the key identifier in kid; the payload carries the claims, which are just JSON key-value pairs. The signature is computed over the literal string header.payload — the exact bytes, including the encoding — using the algorithm named in the header and a key known to the issuer. Decoding the first two segments requires no key at all, which is a common source of confusion: Base64URL is an encoding, not a protection.
Registered claims have fixed meanings. iss identifies the issuer, aud the intended audience, sub the subject, exp the expiry as a Unix timestamp, nbf the moment the token becomes valid, iat when it was issued, and jti a unique identifier used for revocation lists. Validation is not merely a matter of decoding: a service must check that the signature verifies, that the current time is between nbf and exp, that iss matches its own identity, and that aud includes it. A token that decodes cleanly and has not expired can still be rejected for any of the other reasons.
The algorithms split into two families. HS256, HS384 and HS512 are HMAC: the same secret key signs and verifies, which is fine when a single backend owns both ends but means every party that can verify can also forge. RS256 and ES256 are asymmetric: the issuer signs with a private key and services verify with the public key, so a compromised verifier cannot mint tokens. The none algorithm means no signature at all, and the classic JWT vulnerability is a library that reads alg from the token header and accepts none, or accepts HS256 while the server verifies with what is actually an RSA public key.
Signature verification matters because a decoded payload proves nothing on its own. Anyone can craft a token with an admin role and a future expiry; only the signature binds those claims to the issuer. This tool recomputes the signature locally — HMAC through the Web Crypto API for HS*, and RSA-PSS or RSASSA-PKCS1-v1_5 for RS* — and reports a byte-exact comparison, so an invalid-signature error in production can be traced to a wrong secret, a wrong algorithm or a truncated token rather than guessed at.
Casi d'uso comuni
- Inspect the claims in a token copied from an Authorization header to find out which tenant or role it carries.
- Work out whether an expired-token error is genuine by reading the exp timestamp as a date.
- Verify a webhook signature with a shared secret to confirm your HMAC code is correct.
- Check that an identity provider is actually sending the audience your API expects.
- Trace a 401 by comparing the alg and kid in the token against the keys your service has configured.
- Confirm that a token contains no sensitive personal data before logging it.
Ultimo aggiornamento: 2026-10-14 — il corpo dell'articolo è mostrato in inglese; l'interfaccia è tradotta.