What is a JWT?
JWT (JSON Web Token) is a compact, URL-safe token format defined in RFC 7519. It's widely used for stateless authentication in web applications and APIs. A JWT carries user identity and claims without requiring the server to store session state.
JWTs are used by companies like Netflix, Spotify, and Uber to authenticate billions of API requests daily. Learn more in our deep dive: Why JWT Replaced Sessions.
JWT Structure: Three Parts
A JWT has three parts separated by dots: header.payload.signature
- Header: Contains the algorithm (
alg) and token type (typ). Base64URL encoded.
- Payload: Contains claims (statements about the user and metadata like expiration time). Base64URL encoded. Not encrypted, anyone can read it.
- Signature: Cryptographic hash of the header and payload, created with a secret key. Proves the token hasn't been tampered with.
JWT Security Best Practices
- Use short expiration times: 15 minutes for access tokens. Use refresh tokens for longer sessions.
- Store in httpOnly cookies: Prevents XSS attacks from accessing tokens via JavaScript.
- Never put sensitive data in payload: Payloads are encoded, not encrypted. Anyone can decode them.
- Specify allowed algorithms: Prevents algorithm confusion attacks. Always validate
alg on the server.
- Use RS256 for microservices: Only the auth service has the private key; other services verify with the public key.
For the complete guide, read Why JWT Replaced Sessions: Building Auth That Scales and How OAuth 2.0 Works.
Using This JWT Decoder
- Paste a token: Paste any JWT token. The
Bearer prefix is automatically stripped.
- View decoded parts: Header and payload are displayed as formatted JSON with syntax highlighting.
- Check expiration: The
exp claim is automatically compared to the current time.
- Inspect claims: All claims are listed with human-readable descriptions and timestamp formatting.
- Copy JSON: Copy the decoded header or payload to clipboard with one click.
Note: This tool decodes tokens but does not verify signatures. Signature verification requires your secret key, which should never be shared with online tools.