A JSON Web Token (JWT, pronounced “jot”) is a compact, signed piece of JSON that a server gives a client to prove who they are. After you log in, the server issues a token; your browser or app sends it with every request, usually in an Authorization: Bearer <token> header, and the server checks the signature instead of looking up a session. JWTs are defined in RFC 7519.
The three parts of a JWT
A JWT is three Base64URL-encoded strings joined by dots: header, payload and signature.
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyXzEyMyIsIm5hbWUiOiJBbm4gTGVlIiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNzYwMDAwMDAwLCJleHAiOjE3NjAwMDM2MDB9.qQsxyuXRpZqDyVjyHZfuOMFhCtWzMwkSa1HGQhbSCvs
Header
Says how the token is signed:
{
"alg": "HS256",
"typ": "JWT"
}Payload
The claims: statements about the user and the token itself.
{
"sub": "user_123",
"name": "Ann Lee",
"role": "admin",
"iat": 1760000000,
"exp": 1760003600
}Signature
A cryptographic signature of the first two parts, made with the server's secret or private key. If anyone changes a single character of the header or payload, the signature no longer matches and the server rejects the token.
A JWT is signed, not encrypted
This is the most important thing to understand: Base64URL is an encoding, not encryption. Anyone who has the token can read the payload; you can paste the example above into the JWT Decoder or decode each part with the Base64 Converter. The signature only guarantees the data wasn't changed. So never put passwords, card numbers or other secrets in a JWT.
Registered claims
RFC 7519 defines a few standard claim names. All are optional, but most tokens use several:
| iss | Issuer | Who created the token, e.g. your auth server's URL. |
|---|---|---|
| sub | Subject | Who the token is about, usually a user ID. |
| aud | Audience | Which service the token is meant for. |
| exp | Expiration time | When the token stops being valid. |
| nbf | Not before | When the token starts being valid. |
| iat | Issued at | When the token was created. |
| jti | JWT ID | A unique ID, used to detect reuse or revoke a token. |
Times such as exp and iat are Unix timestamps in seconds. In the example, 1760000000 is 9 Oct 2025, 08:53:20 UTC, and the token expires one hour later. The Epoch Converter turns any of these into a readable date; the JWT Decoder does it for you and shows whether the token has expired.
Signing algorithms: HS256, RS256 and ES256
- HS256 (HMAC with SHA-256) uses one shared secret to sign and verify. Simple, but every service that verifies tokens can also create them.
- RS256 (RSA) signs with a private key and verifies with a public key, so other services can check tokens without being able to issue them. Common with identity providers.
- ES256 (ECDSA) works like RS256 with much smaller keys and signatures.
How to decode and verify a JWT
Paste a token into the JWT Decoder to see the header and payload as formatted JSON, every claim explained and the expiry as a date. Open Verify and enter the secret (HS256) or public key (RS256, ES256) to check the signature. Decoding and verifying both happen in your browser, so the token is never sent anywhere. In code, decoding is just Base64URL plus JSON.parse:
const [header, payload] = token.split(".").slice(0, 2).map((part) =>
JSON.parse(atob(part.replace(/-/g, "+").replace(/_/g, "/")))
);
// For real authentication, verify the signature with a library such as jose.Common JWT security mistakes
- Trusting a token without verifying it. Always check the signature on the server, with the algorithm you expect.
- Accepting
alg: none. Unsigned tokens must be rejected; pin the allowed algorithms in your library's settings. - Ignoring
exp. Keep access tokens short-lived (minutes, not months) and use refresh tokens for longer sessions. - Weak HS256 secrets. A short or guessable secret can be brute-forced offline from a single token; use at least 256 random bits.
- Putting secrets in the payload. Remember that anyone can read it.