ITT
All Cheatsheets

JWT Cheatsheet — JSON Web Token Structure & Claims Reference

A concise JWT (JSON Web Token) reference guide. Covers the header, payload, and signature structure, standard claims, and security best practices.

jwt cheatsheet
json web token reference
jwt claims
jwt structure guide
jwt quick reference

JWT Structure

Syntax / PatternMeaningExample / Notes
Formatheader.payload.signatureThree Base64url-encoded parts separated by dots
Header{"alg": "HS256", "typ": "JWT"}Specifies the signing algorithm
Payload{"sub": "1234", "name": "John", "iat": 1516239022}Contains claims (key-value pairs)
SignatureHMACSHA256(base64url(header) + "." + base64url(payload), secret)Verifies the token was not tampered with

Registered Claims (Standard)

Syntax / PatternMeaningExample / Notes
issIssuer — who created the tokene.g. "https://auth.yourapp.com"
subSubject — who the token is aboutUsually a user ID: "user_12345"
audAudience — who the token is fore.g. "https://api.yourapp.com"
expExpiration time (Unix timestamp)Token rejected after this time
nbfNot Before (Unix timestamp)Token invalid before this time
iatIssued At (Unix timestamp)When the token was created
jtiJWT ID — unique identifierUsed to prevent token replay attacks

Common Algorithms

Syntax / PatternMeaningExample / Notes
HS256HMAC + SHA-256 (symmetric)Same secret to sign and verify — for internal use only
RS256RSA + SHA-256 (asymmetric)Private key signs, public key verifies — for APIs
ES256ECDSA + SHA-256 (asymmetric)Smaller keys than RSA, similar security
PS256RSA-PSS + SHA-256More secure than RS256 but less common

Security Rules

Syntax / PatternMeaningExample / Notes
⚠️ Never decode without verifyingAlways verify the signature before trusting claimsatob() decodes — it does NOT verify
⚠️ Check expAlways validate the expiration time claimExpired tokens must be rejected
⚠️ Reject "alg: none"The "none" algorithm means no signatureA major vulnerability if not rejected
✅ Store securelyUse httpOnly cookies, not localStoragelocalStorage is vulnerable to XSS attacks
✅ Short expiryAccess tokens: 15 min. Refresh tokens: 7 daysShorter = less damage if stolen

Frequently Asked Questions

Can I decode a JWT without the secret?

You can decode the header and payload without the secret (they are just Base64url-encoded). However, you cannot VERIFY the signature without the secret or public key. Never trust unverified JWT claims.

Where should I store a JWT?

For web apps: httpOnly Secure cookies are the safest. Avoid localStorage (vulnerable to XSS). Avoid sessionStorage (same risk). Always transmit over HTTPS.

Ready to put this to use?

Test patterns interactively in our live tool.

Open Jwt Decoder

More Cheatsheets