JWT Decoder
Decode and analyze JSON Web Tokens (JWT) to view header, payload, signature, and claims. Inspect token expiration, algorithm, and standard claims. All processing happens in your browser for complete privacy.
About JWT Tokens
JSON Web Tokens (JWT) are a compact, URL-safe means of representing claims between two parties. A JWT consists of three parts separated by dots: Header.Payload.Signature
- Header: Contains the token type (JWT) and signing algorithm (e.g., HS256, RS256)
- Payload: Contains the claims (statements about the user and additional metadata)
- Signature: Used to verify the token's integrity and authenticity
⚠️ Note: This tool only decodes and displays JWT contents. It does not verify signatures or validate tokens. All processing happens in your browser for privacy.
What is a JSON Web Token (JWT)?
JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed using a secret (with HMAC algorithm) or a public/private key pair (using RSA or ECDSA).
JWTs are commonly used for authentication and information exchange in modern web applications. When you log into a website, the server creates a JWT with your user information and sends it back to your browser. Your browser then includes this token in subsequent requests to prove your identity without requiring the server to store session data.
A JWT consists of three parts separated by dots (.), which are: Header.Payload.Signature. Each part is Base64URL encoded, making the entire token URL-safe and easy to transmit in HTTP headers, URLs, or POST parameters.
Understanding JWT Structure
Header
The header typically consists of two parts: the type of token (JWT) and the signing algorithm being used (e.g., HMAC SHA256 or RSA).
{
"alg": "HS256",
"typ": "JWT"
}Payload
The payload contains the claims. Claims are statements about an entity (typically, the user) and additional data. There are three types: registered, public, and private claims.
{
"sub": "1234567890",
"name": "John Doe",
"iat": 1516239022
}Signature
To create the signature, you take the encoded header, encoded payload, a secret, and the algorithm specified in the header, and sign that.
HMACSHA256(
base64UrlEncode(header)
+ "."
+ base64UrlEncode(payload),
secret
)Common Use Cases for JWT
Authentication
The most common scenario for using JWT is authentication. Once a user successfully logs in, the server generates a JWT containing the user's identity and permissions. Each subsequent request includes the JWT, allowing the user to access routes, services, and resources that are permitted with that token. This eliminates the need for server-side session storage.
Information Exchange
JWTs are a secure way to transmit information between parties. Because they can be signed using public/private key pairs, you can be sure the senders are who they claim to be. Additionally, since the signature is calculated using the header and payload, you can verify that the content hasn't been tampered with during transmission.
Single Sign-On (SSO)
JWT is widely used in SSO implementations because of its small overhead and ease of use across different domains. Once authenticated with one service, the JWT can be used to access multiple related services without requiring separate authentication for each. This is particularly useful in microservices architectures.
API Authorization
APIs use JWTs to control access to protected resources. The token can include claims specifying user roles, permissions, and scopes, allowing fine-grained access control. Mobile apps and single-page applications (SPAs) commonly use JWTs to securely communicate with backend APIs without maintaining server-side sessions.
Standard JWT Claims (Registered Claims)
The JWT specification defines several standard claims that provide commonly used information. While these claims are optional, they are widely recognized and recommended for interoperability:
Identifies who issued the JWT. Typically a URL or identifier of the authentication server.
Identifies the subject of the JWT (usually the user ID). Must be unique within the issuer's context.
Identifies the recipients that the JWT is intended for. Can be a string or array of strings.
Unix timestamp after which the JWT must not be accepted. Critical for security to limit token lifespan.
Unix timestamp before which the JWT must not be accepted. Useful for scheduling future access.
Unix timestamp when the JWT was issued. Used to determine the age of a token.
Unique identifier for the JWT. Used to prevent token replay attacks in single-use scenarios.
JWT Signing Algorithms
HMAC Algorithms (HS256, HS384, HS512)
HMAC (Hash-based Message Authentication Code) algorithms use a symmetric key, meaning the same secret key is used for both signing and verification. These algorithms are:
- HS256: HMAC with SHA-256 hash function (most common)
- HS384: HMAC with SHA-384 hash function
- HS512: HMAC with SHA-512 hash function (strongest)
Best for: Applications where the same service creates and verifies tokens. Fast and efficient, but both parties must securely share the secret key.
RSA Algorithms (RS256, RS384, RS512)
RSA algorithms use asymmetric cryptography with a private/public key pair. The private key signs the token, and anyone with the public key can verify it. These algorithms include:
- RS256: RSA Signature with SHA-256 (most common)
- RS384: RSA Signature with SHA-384
- RS512: RSA Signature with SHA-512
Best for: Distributed systems, microservices, or third-party verification where the signing service can keep the private key secure while distributing the public key.
ECDSA Algorithms (ES256, ES384, ES512)
ECDSA (Elliptic Curve Digital Signature Algorithm) also uses asymmetric cryptography but with elliptic curve keys, providing equivalent security to RSA with smaller key sizes:
- ES256: ECDSA with P-256 curve and SHA-256
- ES384: ECDSA with P-384 curve and SHA-384
- ES512: ECDSA with P-521 curve and SHA-512
Best for: Mobile and IoT applications where smaller key sizes reduce bandwidth and processing requirements while maintaining high security.
Frequently Asked Questions
Is JWT the same as OAuth or authentication?
No, JWT is not an authentication protocol—it's a token format. OAuth 2.0 and OpenID Connect are authentication and authorization protocols that often use JWTs as the token format. JWT simply provides a standardized way to represent claims in a compact, URL-safe format. You can use JWTs with various authentication mechanisms including session-based auth, bearer tokens, or OAuth flows.
Does decoding a JWT verify its signature?
No, decoding and verifying are two different operations. Decoding simply reads the Base64URL-encoded header and payload to view their contents—anyone can decode a JWT without any secret or key. Verification, on the other hand, checks the signature using the appropriate key to ensure the token hasn't been tampered with and was issued by a trusted party. Our tool only decodes JWTs; it does not verify signatures.
Can I safely decode sensitive JWTs using this tool?
Yes. All JWT decoding happens entirely in your browser using JavaScript. No data is ever transmitted to our servers or any third party. You can verify this by checking your browser's network activity or by disconnecting from the internet after loading the page—the tool will continue to work. However, remember that JWTs are not encrypted by default, only signed. Anyone with access to a JWT can decode and read its contents.
What does "algorithm: none" mean and why is it dangerous?
The "none" algorithm means the JWT has no signature and provides no cryptographic protection. While technically valid per the JWT spec, it's extremely dangerous in production because anyone can create or modify these tokens. Attackers can change user IDs, permissions, or expiration dates without detection. Some libraries have been vulnerable to accepting "none" algorithm tokens even when expecting signed tokens. Always use proper signing algorithms in production.
How long should a JWT token be valid?
JWT lifetime depends on your security requirements and use case. Access tokens should be short-lived (5-15 minutes) to limit the window of opportunity if compromised. Refresh tokens can last longer (days to weeks) but should be securely stored and rotated. For highly sensitive operations, use even shorter expiration times. Always implement the "exp" (expiration) claim and validate it on the server side. Consider implementing token refresh mechanisms to maintain user sessions without requiring frequent re-authentication.
Should I store sensitive information in a JWT?
Generally, no. JWTs are Base64URL-encoded, not encrypted—anyone who obtains the token can decode and read its contents. Only include information necessary for authorization decisions (user ID, roles, permissions) and avoid sensitive data like passwords, social security numbers, or credit card details. If you must include sensitive data, use JWE (JSON Web Encryption) to encrypt the entire token, or encrypt specific claims before including them in the JWT.
What's the difference between JWT and JWE?
JWT (JSON Web Token) is signed but not encrypted—the header and payload are readable by anyone. JWE (JSON Web Encryption) encrypts the entire content, making it unreadable without the decryption key. JWTs are sufficient when you only need to verify authenticity and integrity. Use JWE when the claims themselves are sensitive and must be kept confidential. JWE tokens are typically longer and require more computational resources to process than JWTs.
Can I revoke or invalidate a JWT before it expires?
JWTs are stateless and self-contained, so they cannot be inherently revoked. Once issued, a JWT remains valid until it expires. However, you can implement revocation through several strategies: maintain a blacklist of revoked tokens, use short expiration times with refresh tokens, include a unique token ID (jti) and check it against a database on each request, or implement token versioning where changing a user's token version invalidates all previous tokens. Each approach has trade-offs between security and performance.
What's the difference between symmetric and asymmetric JWT algorithms?
Symmetric algorithms (HS256, HS384, HS512) use the same secret key for both signing and verification. This is faster but requires both the issuer and verifier to securely share the secret. Asymmetric algorithms (RS256, ES256, etc.) use a private key for signing and a public key for verification. The private key remains secret with the token issuer, while the public key can be freely distributed to anyone who needs to verify tokens. Use symmetric for single-application scenarios and asymmetric for distributed systems or third-party verification.
Where should I store JWTs in a web application?
This is a debated topic in web security. Options include: (1) HttpOnly cookies—protected from XSS but vulnerable to CSRF (mitigate with SameSite attribute), (2) localStorage/sessionStorage —vulnerable to XSS but not CSRF, or (3) memory (JavaScript variables)—most secure but lost on page refresh. For SPAs, many developers use HttpOnly cookies with SameSite=Strict or Lax and CSRF tokens. For mobile apps, use secure platform-specific storage. Never store tokens in regular cookies accessible to JavaScript, and always use HTTPS to prevent token interception.
JWT Security Best Practices
While JWTs provide a convenient way to handle authentication and authorization, following security best practices is crucial to prevent vulnerabilities:
- Always validate signatures: Never accept JWTs without verifying their signature. Implement proper signature verification on the server side using trusted libraries.
- Set short expiration times: Use the "exp" claim and set reasonable expiration times. Access tokens should expire quickly (minutes to hours), while refresh tokens can last longer.
- Validate all claims: Check not just the signature, but also iss (issuer), aud (audience), exp (expiration), and nbf (not before) claims to ensure the token is intended for your application.
- Use HTTPS only: Always transmit JWTs over HTTPS to prevent token interception. Never send tokens in URL parameters where they might be logged.
- Keep secrets secure: Store signing keys securely using environment variables, key management services, or hardware security modules. Never commit keys to version control.
- Implement proper key rotation: Regularly rotate signing keys and support multiple keys simultaneously to allow for smooth transitions without service disruption.
- Don't store sensitive data: Remember that JWTs are encoded, not encrypted. Anyone with access to the token can read its contents.
- Use strong algorithms: Prefer RS256 or ES256 over HS256 for better security in distributed systems. Never use the "none" algorithm in production.
- Implement token refresh: Use short-lived access tokens with separate refresh tokens to balance security and user experience.
- Consider token size: JWTs can grow large with many claims. Monitor token size as it affects bandwidth and can hit header size limits in some servers.
Related Tools
Explore other developer tools to streamline your workflow: