JSON Web Tokens (JWT) are a compact, URL-safe way to represent claims between two parties. They've become the standard for authentication in modern web applications.
What is a JWT?
A JWT consists of three parts separated by dots: Header.Payload.Signature
Header — specifies the token type and signing algorithm:
{
"alg": "HS256",
"typ": "JWT"
}
Payload — contains the claims (user data and metadata):
{
"sub": "1234567890",
"name": "John Doe",
"email": "john@example.com",
"role": "admin",
"iat": 1516239022,
"exp": 1516242622
}
Signature — ensures the token hasn't been tampered with.
When to Use JWT
Common Claims
Security Best Practices
JWT vs Session Cookies
JWT is stateless (server doesn't need to store session data), making it ideal for microservices. Session cookies are simpler for monolithic apps.
Use our JSON Viewer to inspect and debug JWT payloads.