What is a JSON Web Token (JWT)?
Defined in RFC 7519, a JSON Web Token (JWT) is a compact, URL-safe container for transferring claims between two parties. JWTs are widely used in stateless modern authentication architectures (such as OAuth 2.0 and OpenID Connect), allowing backends to verify user identity without hitting an active database session store on every HTTP request.
The Three Parts of a JWT
Every valid JWT contains three distinct parts separated by period (.) delimiters:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkphbmUgRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
1. Header (Algorithm & Token Type)
{
"alg": "HS256",
"typ": "JWT"
}
2. Payload (Claims & User Context)
{
"sub": "user_9831",
"role": "editor",
"email": "jane@company.com",
"exp": 1735689600
}
3. Signature (Tamper Prevention)
HMACSHA256(
base64UrlEncode(header) + "." + base64UrlEncode(payload),
secret_key
)
Decode and Inspect Any JWT Token
Inspect token headers, expiration countdown, and user claims with our secure offline JWT decoder.
Security Rules for Production JWTs
Store tokens in HttpOnly, Secure, SameSite=Strict cookies to protect against XSS token exfiltration. Always enforce expiration (exp) claims.
Never put passwords, credit card numbers, or internal API secret keys inside JWT claims: claims are readable by anyone who inspects the token.
Frequently Asked Questions
+ with -, replaces / with _, and removes trailing padding (=). This ensures the token can be safely placed in HTTP headers and URL query strings without URL-encoding issues.HttpOnly, Secure cookies rather than localStorage. For mobile applications, store tokens in secure hardware keychains.