JWT Decoder
Decode JSON Web Tokens to view header, payload, and signature as formatted JSON. Checks token expiration. All processing happens in your browser.
Key features
- Decode JWT header and payload to readable JSON
- Check token expiration with visual expired/valid badges
- Color-coded JWT parts for easy identification
- No server required - everything happens in your browser
Guide
JSON Web Tokens (JWTs) are the most widely used token format for authentication and authorization in modern web applications. They appear in Authorization headers, OAuth flows, single sign-on systems, API gateways, mobile app sessions, and microservice communication. This tool decodes JWT tokens and displays their header, payload, and signature information in a readable format.
What a JWT Is
A JWT is a compact, URL-safe string that represents a set of claims (assertions about a user or system). It consists of three parts separated by dots: header.payload.signature. Each part is Base64URL-encoded.
The header is a JSON object that specifies the token type and signing algorithm. A typical header looks like {"alg":"RS256","typ":"JWT","kid":"abc123"}. The alg field tells you how the token was signed. The kid (key ID) field identifies which key from a key set was used, which is important when the issuer rotates signing keys.
The payload is a JSON object containing claims. Claims are key-value pairs with information about the user, the token, and the authorization context. The JWT specification (RFC 7519) defines seven registered claims:
- iss (issuer): who created and signed the token, usually a URL like https://auth.example.com
- sub (subject): who the token is about, usually a user ID like user_123 or a UUID
- aud (audience): who the token is intended for, usually an API URL or client ID
- exp (expiration time): Unix timestamp when the token expires and must no longer be accepted
- nbf (not before): Unix timestamp before which the token must not be accepted
- iat (issued at): Unix timestamp when the token was created
- jti (JWT ID): a unique identifier for the token, useful for preventing replay attacks
The payload can also contain custom (private) claims like {"role":"admin","email":"user@example.com","permissions":["read","write"],"tenant_id":"acme"}. Custom claims hold application-specific data that your backend uses for authorization decisions.
The signature is created by signing the Base64URL-encoded header and payload (concatenated with a dot) using the algorithm specified in the header. For HMAC algorithms (HS256), the signature uses a shared secret. For RSA algorithms (RS256), it uses a private key. For ECDSA (ES256), it uses an elliptic curve private key. The signature ensures the token has not been tampered with.
How the Decoder Works
Paste a JWT into the tool and it performs these steps:
1. Splits the token on the dot (.) separators to get three parts 2. Base64URL-decodes the first part (header) and parses it as JSON 3. Base64URL-decodes the second part (payload) and parses it as JSON 4. Displays the third part (signature) as a Base64URL string 5. Converts the exp timestamp to a local date and time 6. Checks whether the token has expired by comparing exp to the current time, and updates the badge every second
Timestamp conversion is one of the most useful features. Raw Unix timestamps like 1711036800 are not intuitive at a glance. The tool shows the exp claim as a local date and time in a badge. The iat and nbf claims stay as raw numbers in the payload, so convert them with a timestamp converter if you need them.
The decoder also flags expired tokens with a clear visual indicator. When you are debugging a 401 Unauthorized error, the first thing to check is whether the token has expired, and the decoder tells you instantly.
This tool decodes but does not verify the signature. Signature verification requires the signing key (a shared secret for HMAC, or a public key for RSA/ECDSA), which the decoder does not have access to. The tool is for inspection, not for security validation. Never trust a JWT's claims based solely on decoding. Always verify the signature on the server side using a JWT library with proper key management.
When to Use the JWT Decoder
Debugging authentication failures is the primary use case. When a user reports being unable to log in or an API returns 401 Unauthorized, the first step is to look at the token. Decode it and check:
- Is the token expired? Compare the exp timestamp to the current time. If exp has passed, the token is invalid. The client needs to refresh it.
- Is the audience correct? The aud claim must match what the API expects. If your API expects "https://api.myapp.com" but the token has "https://api.staging.myapp.com", the validation will fail.
- Is the issuer correct? The iss claim must match the expected identity provider URL. A mismatch means the token came from a different auth system.
- Are the roles/permissions correct? Custom claims like role, scope, or permissions determine what the user can access. If a user lacks access, check these claims.
- Was the token issued recently? A very old iat timestamp might indicate a stale or replayed token.
- Is the algorithm expected? If your server expects RS256 but the token header says HS256, this could indicate an algorithm confusion attack.
OAuth2 and OpenID Connect (OIDC) debugging is another major use case. OAuth flows produce access tokens, refresh tokens, and ID tokens. The ID token (in OIDC) is always a JWT. Decoding it shows you the user's identity claims (sub, email, name), the scopes granted (scope), the client ID (azp), the nonce (for replay prevention), and the token lifetime.
Access tokens in OAuth2 are not required to be JWTs, but many providers (Auth0, Okta, Azure AD, Firebase) issue them as JWTs. Decoding the access token reveals the granted scopes, the intended audience, and when the token expires. This information helps you debug permission errors.
API development and testing frequently involves JWTs. When you build an endpoint that accepts JWTs, you need to generate test tokens, inspect them, and verify that your validation logic handles edge cases: expired tokens, wrong audience, missing required claims, different algorithms, and malformed tokens.
Security auditing uses JWT decoding to check for common vulnerabilities. Inspect tokens from your application to verify that sensitive data is not stored in the payload, that token lifetimes are reasonable (not 30 days for an access token), and that the algorithm is appropriate (not "none" or weak HMAC with a guessable secret).
Microservice debugging: in a microservice architecture, JWTs often pass through multiple services. Decode the token at each hop to verify claims are preserved and not modified incorrectly.
JWT Structure Deep Dive
A real JWT looks like this:
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InNpZzEifQ.eyJzdWIiOiJ1c2VyXzQ1NiIsIm5hbWUiOiJBbGljZSBKb2huc29uIiwiaWF0IjoxNzExMDM2ODAwLCJleHAiOjE3MTEwNDA0MDAsImlzcyI6Imh0dHBzOi8vYXV0aC5leGFtcGxlLmNvbSIsImF1ZCI6Imh0dHBzOi8vYXBpLmV4YW1wbGUuY29tIiwicm9sZSI6ImFkbWluIiwicGVybWlzc2lvbnMiOlsicmVhZCIsIndyaXRlIiwiZGVsZXRlIl19.signature_bytes_here
Decoding the header: {"alg":"RS256","typ":"JWT","kid":"sig1"} Decoding the payload: {"sub":"user_456","name":"Alice Johnson","iat":1711036800,"exp":1711040400,"iss":"https://auth.example.com","aud":"https://api.example.com","role":"admin","permissions":["read","write","delete"]}
From this decoded view, you immediately know: the token uses RS256 signing with key ID "sig1", belongs to user_456 (Alice Johnson), was issued at a specific time, expires one hour later, was issued by auth.example.com for api.example.com, and grants admin role with read/write/delete permissions.
Signing Algorithms
HS256 (HMAC-SHA256): A symmetric algorithm using a shared secret. The same key signs and verifies the token. Simple to implement but the secret must be known by both the issuer and every verifier. If any verifier is compromised, the secret is exposed and an attacker can forge tokens. Use HS256 only in environments where you fully control all parties (like internal services behind a firewall).
RS256 (RSA-SHA256): An asymmetric algorithm. The issuer signs with a private key, and verifiers use the corresponding public key. The public key can be freely distributed (usually via a JWKS endpoint like https://auth.example.com/.well-known/jwks.json) without compromising security. This is the recommended algorithm for most production systems. Even if a verifier is compromised, the attacker only gets the public key and cannot forge tokens.
ES256 (ECDSA-SHA256): Another asymmetric algorithm using elliptic curve cryptography. Produces shorter signatures than RS256 (64 bytes vs. 256 bytes) with equivalent security strength. Signing is faster than RSA, verification is slightly slower. Increasingly popular in new systems and required by some specifications (like Apple's Sign in with Apple).
PS256 (RSA-PSS-SHA256): A more modern RSA variant with a probabilistic signature scheme. Offers better security properties than PKCS#1 v1.5 (used in RS256) but is less widely supported. Used in some government and financial specifications.
EdDSA: Uses Edwards-curve Digital Signature Algorithm (typically Ed25519). Produces very short signatures, is fast, and has strong security properties. Gaining adoption but not yet as widely supported as RS256 or ES256.
The algorithm is specified in the header's alg field. When the decoder shows you the algorithm, you know how the token was signed and what kind of key is needed for verification.
Common JWT Security Issues
Algorithm confusion (alg:none attack): If a server naively reads the algorithm from the token header and accepts "none" as a valid algorithm, an attacker can create unsigned tokens with any claims. The fix: always validate the algorithm against an allowlist on the server. Better yet, ignore the header's alg field entirely and configure the expected algorithm in your verification code.
HS256/RS256 confusion: If a server is configured to accept RS256 tokens but the verification library also accepts HS256, an attacker can create an HS256 token signed with the server's RSA public key (which is publicly available). The verification succeeds because the library treats the public key as the HMAC secret. The fix: explicitly specify the expected algorithm and reject all others.
Secret brute forcing: HS256 tokens signed with weak secrets can be cracked. Tools like hashcat can test billions of potential secrets per second. Use a random secret of at least 256 bits (32 bytes). If you can decode a token and the algorithm is HS256, the security depends entirely on the secret's strength. A password like "mysecretkey" is crackable in seconds.
Sensitive data in payload: JWTs are encoded, not encrypted. Anyone who intercepts the token can decode the payload. The Base64URL encoding provides zero confidentiality. Never put passwords, credit card numbers, social security numbers, medical records, or other sensitive data in JWT claims. The payload should contain identifiers (user ID, tenant ID) and authorization data (roles, scopes), not sensitive personal information.
Long token lifetimes: Access tokens should expire in minutes to hours (15 minutes is common for high-security applications, 1 hour is standard). Refresh tokens can live longer (days to weeks) but should be stored securely and be revocable. A token with a 30-day expiration is a 30-day window for an attacker who steals it. Short-lived access tokens limit the damage window.
No token revocation: Standard JWTs are stateless. Once issued, they are valid until expiration. If a user's account is compromised, sessions are invalidated, or permissions change, you cannot revoke existing tokens without additional infrastructure. Options include: a server-side blocklist of revoked token IDs (jti), very short-lived tokens (5-15 minutes) with frequent refresh, or a token version number stored per-user that invalidates all older tokens.
Token leakage: JWTs in URL query parameters get logged in server access logs, browser history, and referrer headers. Always send JWTs in the Authorization header, not in URLs.
Common Mistakes
Mistake 1: Confusing encoding with encryption. Base64URL encoding is reversible by anyone. A JWT payload is readable by any person or system that has the token. The signature provides integrity (proof the token was not tampered with) and authenticity (proof it was issued by the expected party), but not confidentiality. If you need confidentiality, use JWE (JSON Web Encryption).
Mistake 2: Not checking expiration on the server. The server must validate the exp claim on every request. Client-side expiration checks are a user experience convenience, not a security measure. An attacker can ignore client-side checks.
Mistake 3: Storing JWTs in localStorage. localStorage is accessible to any JavaScript running on the page, including injected scripts from XSS attacks. Use httpOnly, secure, SameSite cookies for JWT storage when possible. If you must use localStorage (for example, in a cross-origin API scenario), ensure robust XSS protection with Content Security Policy and input sanitization.
Mistake 4: Ignoring clock skew. The server's clock and the issuer's clock may differ by a few seconds. Most JWT libraries accept a configurable leeway (typically 30-60 seconds) for the exp and nbf claims. Without this leeway, tokens may appear expired immediately after issuance if the clocks are slightly out of sync.
Mistake 5: Bloated tokens. Every claim you add increases the token size. JWTs are sent with every HTTP request in the Authorization header. A 4KB token on every API call adds up, especially on mobile networks. Keep claims minimal: user ID, role, issuer, audience, and expiration are usually sufficient. Look up additional user data from a database or cache when needed. If your token exceeds 2KB, reconsider what you are putting in it.
Advanced Tips
When debugging token issues across services, decode the token at each step of the flow: after the identity provider issues it, after your API gateway processes it, and when it reaches your backend service. Compare the decoded payloads to find where claims are modified, removed, or corrupted.
Use the decoded exp and iat timestamps to calculate token lifetime. If iat is 1711036800 and exp is 1711040400, the lifetime is 3600 seconds (1 hour). If you see unexpectedly short lifetimes (tokens expiring in seconds) or long lifetimes (tokens valid for months), check your identity provider's token lifetime configuration.
For OpenID Connect ID tokens, the nonce claim prevents replay attacks. The decoded token should contain the nonce you sent in the authentication request. If it does not match, the token might be replayed from a previous session.
The kid (key ID) in the header tells you which key from the provider's JWKS (JSON Web Key Set) endpoint was used to sign the token. When debugging signature verification failures, check that your application is fetching the correct JWKS endpoint and that the kid matches an available key. Key rotation issues (the signing key was rotated but your app cached the old key set) are a common cause of sudden verification failures.
When building microservices, decode tokens in your API gateway to extract routing information (tenant ID, region, user tier) and pass those as headers to downstream services. This avoids redundant decoding at every service and lets internal services trust the gateway's extraction.
If you need to create test JWTs for development, use jwt.io or a library like jose (JavaScript), PyJWT (Python), or golang-jwt (Go). Create tokens with specific claims, expiration times, and algorithms to test your validation logic's edge cases: expired tokens, wrong audience, missing required claims, unsupported algorithms, and malformed tokens.
JWT Libraries and Best Practices
Choosing the right JWT library matters for security. Use well-maintained libraries that default to safe behavior.
JavaScript/TypeScript: jose (by panva) is the most recommended library. It supports all standard algorithms, JWKS key fetching, and has no dependencies. jsonwebtoken (by auth0) is widely used but older. Avoid writing JWT verification code from scratch.
Python: PyJWT is the standard library. python-jose supports JWS and JWE. For Django, use djangorestframework-simplejwt. For Flask, use flask-jwt-extended.
Java: nimbus-jose-jwt is comprehensive and well-maintained. java-jwt by Auth0 is simpler. Spring Security has built-in JWT support.
Go: golang-jwt/jwt (v5) is the maintained fork of dgrijalva/jwt-go. Use it for both signing and verification.
Rust: jsonwebtoken crate is the standard choice. It supports HMAC, RSA, and ECDSA.
Regardless of language, follow these practices: always specify the expected algorithm when verifying (never let the token dictate the algorithm), always validate exp, iss, and aud claims, fetch JWKS keys with caching and rotation support (not hardcoded public keys), reject tokens with alg:none, and log (but do not expose to users) the reason for token rejection.
JWTs in Single Page Applications
Single page applications (SPAs) face unique challenges with JWT storage and lifecycle.
The recommended approach for SPAs that communicate with a same-origin backend: use httpOnly cookies. The backend sets the JWT as an httpOnly, secure, SameSite=Strict cookie. JavaScript cannot access it (preventing XSS theft), and the browser automatically includes it in requests. CSRF protection is handled by the SameSite flag and/or a CSRF token.
For SPAs that call third-party APIs or cross-origin backends: store the access token in memory (a JavaScript variable) and the refresh token in an httpOnly cookie (via a same-origin BFF endpoint). When the page reloads, the in-memory token is lost, but the app can silently get a new access token using the refresh token cookie. This approach minimizes the token's exposure.
Avoid: storing tokens in localStorage (XSS-accessible), storing tokens in sessionStorage (XSS-accessible, lost on tab duplication), and storing tokens in regular cookies (XSS-accessible unless httpOnly). The attack surface matters because any XSS vulnerability on your page gives the attacker access to non-httpOnly storage.
Frequently asked questions
What is a JWT?
A JSON Web Token is a compact, URL-safe way to represent claims between parties. It has three parts: header, payload, and signature.
Is it safe to paste my JWT here?
Yes. Everything is processed in your browser. No data is sent to any server.
Related guides
- JWT Decoder Checklist: Three Parts, One Padding Fix, and an Expiry Trap
- JWT Authentication Explained: Complete Guide for Developers
