JWT Cheat Sheet

How JSON Web Tokens work, what every common claim and header means, which algorithm to choose, and the checks every server must make.

Cheat sheetPrintableFree, no login

Updated 28 October 2026

Decode a token, watch its expiry countdown and verify its signature — all in your browser.

Open the JWT decoder

JWT structure

eyJhbGciOiJIUzI1NiJ9 . eyJzdWIiOiJ1MSIsImV4cCI6MTc5MzEzNjk0NH0 . 4QqPoCaM-dIEMoFGEy3...
└──── header ─────┘   └──────────────── payload ─────────────────┘   └── signature ──┘
{"alg":"HS256"}        {"sub":"u1","exp":1793136944}                  HMAC or signature bytes

Registered claims

ClaimNameTypeMeaning
issIssuerString (URL)Who created and signed the token
subSubjectStringWho the token is about — usually the user ID
audAudienceString or arrayWho the token is meant for. The receiver must check it matches
expExpiration timeNumber (seconds)Reject the token at or after this time
nbfNot beforeNumber (seconds)Reject the token before this time
iatIssued atNumber (seconds)When the token was created
jtiJWT IDStringUnique ID, used to block replays or revoke a token

These seven are the registered claims from RFC 7519. All are optional, but most APIs require exp, iss and aud.

Common OpenID Connect and OAuth claims

ClaimMeaning
name given_name family_nameThe user's names
email email_verifiedEmail address and whether the provider checked it
preferred_usernameUsername shown in apps
pictureURL of the profile picture
auth_timeWhen the user last signed in (seconds)
nonceTies an ID token to one sign-in request, to stop replays
azpAuthorized party — the client the token was issued to
at_hashHash that binds an ID token to its access token
amr acrHow the user signed in (e.g. pwd, mfa) and how strong that was
scope / scpPermissions granted to an access token (OAuth)
roles groupsApp or directory roles (provider-specific)

Algorithms: HS256 vs RS256 vs ES256

AlgorithmTypeKeyUse it when
HS256 HS384 HS512HMAC (shared secret)Random secret, at least 32 / 48 / 64 bytesThe same service creates and checks the token
RS256 RS384 RS512RSA PKCS#1 v1.5RSA key pair, 2048 bits or moreMany services verify; most widely supported
PS256 PS384 PS512RSA-PSSRSA key pair, 2048 bits or moreLike RS256, with a more modern padding scheme
ES256 ES384 ES512ECDSA (P-256 / P-384 / P-521)EC key pairShort signatures, fast — good for mobile and IoT
EdDSAEd25519Ed25519 key pairModern and fast, where your libraries support it
noneUnsigned—Never accept. Anyone can edit an unsigned token

Security checklist

Verify a JWT in code

Each example checks the signature with a fixed algorithm and validates the issuer, audience and expiry.

// Node.js — npm install jsonwebtoken
const jwt = require('jsonwebtoken');
const claims = jwt.verify(token, publicKey, {
  algorithms: ['RS256'],
  issuer: 'https://auth.example.com',
  audience: 'my-api',
});
# Python — pip install pyjwt[crypto]
import jwt
claims = jwt.decode(
    token, public_key,
    algorithms=["RS256"],
    issuer="https://auth.example.com",
    audience="my-api",
)
// Go — github.com/golang-jwt/jwt/v5
tok, err := jwt.Parse(tokenString,
    func(t *jwt.Token) (any, error) { return publicKey, nil },
    jwt.WithValidMethods([]string{"RS256"}),
    jwt.WithIssuer("https://auth.example.com"),
    jwt.WithAudience("my-api"),
)

Common JWT errors

Error (Node.js jsonwebtoken)MeaningWhat to check
jwt expiredThe exp time has passedGet a new token; check the server clock
invalid signatureThe signature doesn't matchWrong secret or key, or the token was edited
jwt malformedNot three Base64URL partsMissing Bearer handling, or a truncated token
invalid algorithmThe token's alg isn't in your allow-listIssuer and verifier must agree on the algorithm
jwt audience invalidaud doesn't matchThe token was issued for another app
jwt issuer invalidiss doesn't matchThe token comes from another issuer or environment
jwt not activeBefore the nbf timeClock skew between servers

Other libraries use similar wording, for example PyJWT raises ExpiredSignatureError and InvalidSignatureError.

Frequently asked questions

Is a JWT encrypted?
No — a normal JWT (a JWS) is only signed. The header and payload are Base64URL-encoded, so anyone with the token can read them. Encrypted JWTs (JWE) have five parts instead of three.
Can I decode a JWT without the secret?
Yes. Decoding only needs Base64URL. The secret or public key is needed to verify the signature, which proves the token wasn't changed.
Should I use HS256 or RS256?
Use HS256 when one service both creates and checks tokens and can keep a shared secret. Use RS256 (or ES256) when other services need to verify tokens: they get only the public key, so they can't create tokens.
How long should a JWT be valid?
Access tokens are usually valid for 5–60 minutes, paired with a longer-lived refresh token. Short lifetimes limit the damage if a token leaks, because JWTs can't easily be revoked.
What is the alg: none attack?
A token with "alg": "none" has no signature, so anyone can change its claims. Some old libraries accepted these tokens. Always verify with a fixed list of allowed algorithms.
✓ Copied!