Decode and analyze JSON Web Tokens (JWT).
A JSON Web Token (JWT) is an open standard (RFC 7519) for securely transmitting information between parties as a JSON object. JWTs are widely used for authentication and authorization in modern web applications, APIs, and microservices architectures.
JWTs are self-contained tokens—they carry all the information needed to verify their authenticity and extract user data, eliminating the need for server-side session storage. This makes them ideal for stateless authentication in distributed systems.
A JWT consists of three parts separated by dots (.):
Contains token type and signing algorithm.
{
"alg": "HS256",
"typ": "JWT"
}
Contains claims (user data and metadata).
{
"sub": "1234567890",
"name": "John Doe",
"iat": 1516239022
}
Verifies the token hasn't been tampered with.
HMACSHA256(
base64(header) + "." +
base64(payload),
secret
)
The JWT specification defines several registered claims with specific meanings:
| Claim | Name | Description |
|---|---|---|
iss |
Issuer | Who issued the token (e.g., your auth server URL) |
sub |
Subject | The subject of the token (usually user ID) |
aud |
Audience | Intended recipient(s) of the token |
exp |
Expiration Time | Unix timestamp when token expires |
nbf |
Not Before | Unix timestamp before which token is not valid |
iat |
Issued At | Unix timestamp when token was issued |
jti |
JWT ID | Unique identifier for the token |
HS256 - HMAC with SHA-256HS384 - HMAC with SHA-384HS512 - HMAC with SHA-512Same secret key signs and verifies. Simpler but requires secure key sharing.
RS256 - RSA with SHA-256RS384 - RSA with SHA-384RS512 - RSA with SHA-512ES256 - ECDSA with SHA-256Private key signs, public key verifies. Better for distributed systems.
Bearer <token>Never create tokens without expiration. Short-lived tokens (15 minutes to 1 hour) limit the damage if a token is stolen. Use refresh tokens for longer sessions.
Always verify the algorithm matches what you expect. The infamous "alg: none" attack exploits servers that accept unsigned tokens. Never accept "alg": "none" in production.
For HMAC algorithms, use cryptographically random secrets at least 256 bits long. Weak secrets can be brute-forced to forge tokens.
JWT payloads are base64-encoded, not encrypted. Anyone can decode and read them. Never include passwords, credit cards, or other sensitive data in the payload.
| Factor | JWT | Server Sessions |
|---|---|---|
| Scalability | Excellent - stateless | Requires session store |
| Revocation | Difficult - needs blocklist | Easy - delete session |
| Storage | Client-side | Server-side |
| Microservices | Great fit | Needs shared store |
| Mobile Apps | Works well | Cookie handling issues |
This decoder cannot verify signatures because it doesn't have access to the secret key.
To verify a JWT's authenticity, you need the secret key (for HMAC) or public key (for RSA/ECDSA).