What is a JWT Token?
JSON Web Token (JWT) is an open standard (RFC 7519) for securely transmitting information between parties as a JSON object. JWTs are commonly used for authentication and authorization in web applications.
JWT Structure
A JWT consists of three parts separated by dots (.), each Base64URL encoded:
1. Header
Contains metadata about the token, typically the signing algorithm (alg) and token type (typ).
{
"alg": "HS256",
"typ": "JWT"
}2. Payload
Contains the claims—statements about the user and additional metadata.
{
"sub": "1234567890",
"name": "John Doe",
"iat": 1516239022,
"exp": 1516242622
}3. Signature
Created by signing the encoded header and payload with a secret key. Verifies the token hasn't been tampered with.
HMACSHA256( base64UrlEncode(header) + "." + base64UrlEncode(payload), secret )
Common JWT Claims
Claims are pieces of information about the subject (user). There are three types:
Registered Claims (Standard)
| Claim | Name | Description |
|---|---|---|
| iss | Issuer | Who issued the token |
| sub | Subject | Who the token is about (user ID) |
| aud | Audience | Intended recipient |
| exp | Expiration | When the token expires (Unix timestamp) |
| nbf | Not Before | Token not valid before this time |
| iat | Issued At | When the token was created |
| jti | JWT ID | Unique identifier for the token |
Custom Claims
You can add any custom claims your application needs, such as:
name— User's nameemail— User's emailrole— User's role (admin, user, etc.)permissions— Array of permissions
How JWT Authentication Works
- Login: User sends credentials to the server
- Token Creation: Server verifies credentials and creates a JWT
- Token Storage: Client stores the JWT (usually in localStorage or cookies)
- Authenticated Requests: Client sends JWT in the Authorization header
- Token Verification: Server verifies the signature and checks expiration
JWT Security Best Practices
✓ Do
- • Use strong secrets and asymmetric keys (RS256) for production
- • Set short expiration times (exp claim)
- • Validate all claims on the server
- • Use HTTPS for all token transmission
- • Store tokens securely (httpOnly cookies preferred)
✗ Don't
- • Don't store sensitive data in the payload (it's not encrypted)
- • Don't use weak secrets like "secret"
- • Don't ignore token expiration
- • Don't store tokens in localStorage if XSS is a concern
- • Don't use the none algorithm in production
Common Signing Algorithms
| Algorithm | Type | Use Case |
|---|---|---|
| HS256 | Symmetric | Simple apps, same party signs and verifies |
| RS256 | Asymmetric | Distributed systems, public key verification |
| ES256 | Asymmetric | Modern apps, smaller signature size |
Decode Your JWT
Use our JWT decoder to inspect any token's header, payload, and signature. See expiration status and all claims at a glance.
Open JWT Decoder →