JWT Encode/Decode Online
Build and debug JWTs without a server — sign with HS256/384/512, RS256/384/512, PS256/384/512, or ES256/384/512. Verify tokens with JWKS-based key matching, live expiry countdowns, and a claim validation checklist.
ResultLeave empty to preview the token with a signature placeholder.
What is JWT (JSON Web Token)?
A JSON Web Token (JWT) is a compact, URL-safe way to represent claims between two parties. It has three dot-separated parts: a header (the algorithm and type), a payload (the claims), and a signature that proves the header and payload have not been tampered with. JWTs are widely used in modern web applications to handle authentication and authorization efficiently without constant database lookups. If you work with identity providers, see our OIDC ID Token tool — it covers the RS256/JWKS side of JWT verification. For a security-first alternative, try our PASETO tool, or for server-managed sessions, our opaque token generator.
This tool goes beyond a basic encoder/decoder:
The payload is encoded, not encrypted — anyone can read it. Never put secrets in a JWT.
Zero-Server Tool Data Guarantee
All encoding, decoding, and signature verification happens entirely in your browser using the Web Crypto API. Your tokens, secrets, keys, and any JWKS documents you fetch are never transmitted to or stored by this site. The only network request is the optional JWKS URL you choose to fetch, which goes directly from your browser to that issuer over HTTPS.
How to Use
Choose a mode
Use Encode to build a new token or Decode / Verify to inspect and check an existing one.
Pick an algorithm and key
For HS256/384/512 enter a shared secret. For asymmetric algorithms (RS*/PS*/ES*) paste a PKCS#8 private key or private JWK to sign, and a JWK / PEM public key or JWKS URL to verify.
Use claim templates
Insert common iss/sub/aud payload shapes, then set exp to now + 15 minutes or now + 1 hour with one click.
Read the checklist
In Decode / Verify, watch the live exp/nbf countdown and progress bar, and check whether iss and aud match the expected values.
Common Use Cases
API Auth Testing
Mint HS256/HS384/HS512 tokens with arbitrary claims to test how your API validates expiry, issuer, and audience.
OIDC / SSO Debugging
Fetch an identity provider's JWKS URL and verify a real RS256 or ES256 ID Token, matching the signing key by kid.
Signature Verification
Check whether a token's signature is genuinely valid — not just decodable — using a JWK, PEM public key, or JWKS endpoint.
Security Education
Demonstrate the RS256→HS256 algorithm-confusion attack and why allowlisting algorithms is non-negotiable.
API Authentication & Authorization
The most common use. After a user logs in, the server issues a JWT. This token is then sent with every subsequent API request to prove the user's identity and permissions.
Single Sign-On (SSO)
When a user logs into one service, they can seamlessly access other related services within the same ecosystem without re-authenticating, all powered by shared JWTs.
Information Exchange
Securely transmitting information between trusted parties. For instance, a payment gateway might use a JWT to confirm a transaction's integrity back to your application.
OAuth 2.0
Often used as the format for access tokens in OAuth 2.0 flows, allowing clients to access protected resources on behalf of a user.
Implementation Examples
// Install: npm install jsonwebtokenconst jwt = require('jsonwebtoken');const payload = { userId: '123', role: 'admin', exp: Math.floor(Date.now() / 1000) + 3600 };const secret = 'your-super-secret-key'; // Keep this safe!// Signing (pick HS256 / HS384 / HS512)const token = jwt.sign(payload, secret, { algorithm: 'HS256' });console.log('Generated JWT:', token);// Verification — ALWAYS pin the algorithm listtry {const decoded = jwt.verify(token, secret, { algorithms: ['HS256'] });console.log('Decoded Payload:', decoded);} catch (err) {console.error('JWT Verification Failed:', err.message);}
JWT vs. PASETO vs. Traditional Session Tokens
| Feature | JWT (JSON Web Token) | PASETO (Platform-Agnostic Security Token) | Traditional Session Tokens (Cookies) |
|---|---|---|---|
| Design Philosophy | Flexible, widely adopted, claims in payload. | Security-first, explicit design, no algorithm agility. | Server-side state, opaque tokens (pointers). |
| Mutability | Payload is verifiable but not encrypted (by default). | Encrypted (Local) or Signed (Public) by design. | Opaque, server determines validity/state. |
| Algorithm Agility | Allows various algorithms (HS256, RS256, etc.) which can be a source of vulnerabilities if not handled correctly. | Fixed algorithms, no agility (prevents algorithm confusion attacks). | N/A (token is an identifier, not a crypto object). |
| Default Security | Requires careful implementation to avoid pitfalls. | Stronger defaults, harder to misuse. | Relies on server-side session management. |
| Key Management | Symmetric (HS) or Asymmetric (RS) keys. | Symmetric (Local) or Asymmetric (Public) keys, explicitly defined. | Server-side lookup. |
| Use Case | General-purpose auth, APIs, SSO. | High-security APIs, microservices, strong guarantees. | Traditional web apps (server-rendered). |
HS256/384/512 vs RS256 vs ES256
| Feature | HS256/384/512 | RS256 | ES256 |
|---|---|---|---|
| Family | HMAC (symmetric) | RSA PKCS#1 v1.5 (asymmetric) | ECDSA P-256 (asymmetric) |
| Key | One shared secret | Private key signs; public key verifies | EC private key signs; public key verifies |
| Key exchange | Must be shared securely | Public key is safe to distribute | Public key is safe to distribute |
| Signature size | Hash size (32/48/64 bytes) | Key size (typically 256 bytes for 2048-bit RSA) | 64 bytes |
| Best for | Single-service APIs, same trust domain | Multi-service verification without sharing secrets | Compact signatures, high-traffic / constrained clients |
| Cost | Cheapest | Moderate (RSA verify is cheap, sign slower) | Very fast both ways |
Production Best Practices & Security
Frequently Asked Questions
HS256 uses a single shared secret for both signing and verification. Anyone with the secret can create or verify tokens.
RS256 uses asymmetric key pairs: a private key signs tokens, and anyone with the public key can verify them.
Use HS256 for simple architectures where the signer and verifier are the same system. Use RS256 when multiple services need to verify tokens without sharing a secret — think microservices or third-party integrations.
RS256 is more secure but requires key management infrastructure.