What Is a JWT (JSON Web Token)? Explained Simply
A JWT is a compact, signed token used to securely transmit claims like user identity between parties. Learn its three-part structure and how verification works.
Published September 22, 2026
A JWT is a compact, signed string with three parts (header.payload.signature) that carries claims such as a user id. The server can verify the signature without storing a session.
The concept
The header names the algorithm, the payload holds claims like sub and exp, and the signature is created with a secret or private key so tampering is detectable.
The payload is only Base64URL-encoded, not encrypted: anyone can read it. Never put secrets inside a JWT.
Three parts
Practical examples
Decoded payload
{ "sub": "7", "role": "admin", "exp": 1893456000 }Send it with requests
GET /api/me
Authorization: Bearer eyJhbGciOi...Verify in Node
import jwt from 'jsonwebtoken'
const data = jwt.verify(token, process.env.JWT_SECRET)Issue a short-lived token
jwt.sign({ sub: user.id }, secret, { expiresIn: '15m' })Common mistakes
- Storing sensitive data in the payload.
- Long expiry times with no revocation plan.
- Accepting alg: none or not pinning the algorithm.
- Keeping tokens in localStorage on XSS-prone sites.
Key takeaways
- Signed, not encrypted.
- Keep it short-lived.
- Always verify signature and exp.
FAQ
JWT vs session?
JWTs are stateless but hard to revoke; sessions are revocable but need server storage.
Can I decode one online?
Yes, on this site's JWT tool, which does it in your browser.