Published March 5, 2026 • 10 min read
JWT is the most widely used token format for API authentication. This tutorial explains the structure, how signatures work, and how to decode and verify JWTs — with no fluff.
Decode a JWT Now →JWT stands for JSON Web Token. It is an open standard (RFC 7519) that defines a compact, self-contained way to securely transmit information between parties as a JSON object.
A JWT looks like this:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkFsaWNlIiwiaWF0IjoxNzQwOTg3MjAwfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Three parts separated by dots (.): Header . Payload . Signature
The header specifies the token type and signing algorithm. It is Base64URL encoded.
{
"alg": "HS256",
"typ": "JWT"
}
alg is the algorithm: HS256 (HMAC-SHA256), RS256 (RSA), ES256 (ECDSA). typ is always JWT.
The payload contains the claims — statements about the user and additional metadata. Also Base64URL encoded.
{
"sub": "1234567890",
"name": "Alice",
"email": "alice@example.com",
"role": "admin",
"iat": 1740987200,
"exp": 1741073600
}
Standard claims: sub (subject/user ID), iat (issued at), exp (expiration), iss (issuer), aud (audience).
Important: The payload is only encoded, not encrypted. Anyone can read it. Never put passwords or sensitive data in a JWT payload.
The signature verifies the token has not been tampered with. It is computed as:
HMACSHA256( base64UrlEncode(header) + "." + base64UrlEncode(payload), secret )
Only parties that know the secret (or the private key for RS256) can create valid tokens. Anyone can verify the signature using the public key.
Authorization: Bearer <token> header on every requestSince the header and payload are Base64URL encoded (not encrypted), you can decode them without the secret:
In JavaScript:
function decodeJWT(token) {
const [header, payload] = token.split('.');
const decode = str => JSON.parse(atob(str.replace(/-/g, '+').replace(/_/g, '/')));
return {
header: decode(header),
payload: decode(payload)
};
}
const decoded = decodeJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...');
console.log(decoded.payload.name); // "Alice"
Or use the free JWT Decoder tool — paste your token and instantly see the decoded header, payload, claims, and expiry time.
| Algorithm | Type | Use Case |
|---|---|---|
| HS256 | Symmetric (shared secret) | Single server, simple apps |
| RS256 | Asymmetric (RSA key pair) | Microservices, third-party verification |
| ES256 | Asymmetric (ECDSA) | High-security apps, smaller key size |
| none | No signature | Never use in production |
exp claim server-side. A decoded token does not mean it is valid.alg: "none" which bypasses signature verification. Always whitelist allowed algorithms.OAuth is an authorization framework that defines how applications can obtain limited access to user accounts. JWT is a token format. OAuth commonly uses JWTs as its access tokens, but OAuth can also use opaque tokens. They are complementary, not competing.
Access tokens should expire in 15 minutes to 1 hour. Use refresh tokens (longer-lived, stored in httpOnly cookies) to silently issue new access tokens. Short expiry limits the damage if a token is stolen.
No. JWT tokens must be transmitted over HTTPS. Over plain HTTP, tokens can be intercepted by a man-in-the-middle attack. Always use TLS in production.
Use the JWT Decoder at JSON Web Tools. Unlike jwt.io, your token is decoded entirely in your browser and never sent to any server, making it safe to use with real tokens during debugging.
Free, private, runs entirely in your browser. No data sent to servers.
Open JWT Decoder →Also read: JSON vs XML | JSON Schema Tutorial | How to Validate JSON