How to Decode and Verify JWT Tokens: Client-Side Security & Claims Guide
Quick Tool: Looking for a free online solution? Try the Free JWT Decoder & Verifier on MafLabs to get this done directly in your browser with zero install and 100% privacy.
JSON Web Tokens (JWT) are the standard authentication mechanism for modern web applications, microservices, and mobile APIs. Whenever you sign in with OAuth2, OpenID Connect, or Firebase Auth, a compact, URL-safe token is passed across your network headers.
However, debugging auth tokens often introduces security risks—especially when developers unknowingly paste production JWTs containing sensitive employee claims or private session tokens into third-party servers.
1. The Anatomy of a JSON Web Token
A standard JWT (RFC 7519) consists of three distinct parts separated by dots (.):
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkFsZXgiLCJpYXQiOjE1MTYyMzkwMjJ9.4z9...
- Header (Red): Identifies the token type (
JWT) and the cryptographic signing algorithm (such asHS256orRS256). - Payload (Purple): Contains the claims—entity data, user IDs, roles, and temporal expiration timestamps.
- Signature (Cyan): The cryptographic hash computed using your secret key or private key to ensure the token has not been tampered with.
2. Standard Registered Claims Explained
RFC 7519 defines several standard registered claims that every engineer must understand:
| Claim | Full Name | Description |
|---|---|---|
exp |
Expiration Time | Unix epoch timestamp after which the token MUST NOT be accepted. |
iat |
Issued At | Unix epoch timestamp recording when the token was generated. |
nbf |
Not Before | Identifies the time before which the token must not be accepted. |
iss |
Issuer | Identifies the principal that issued the token (e.g. https://auth.company.com). |
sub |
Subject | Identifies the principal that is the subject of the JWT (e.g. user ID). |
aud |
Audience | Identifies the recipients that the JWT is intended for. |
3. How to Verify Signatures: Symmetric vs. Asymmetric
A. Symmetric Signatures (HS256 / HS384 / HS512)
Uses a shared secret string known to both the token issuer and consumer. You can verify it client-side with the browser's native Web Crypto API:
// Browser Web Crypto API verification example
const key = await window.crypto.subtle.importKey(
"raw",
new TextEncoder().encode(secret),
{ name: "HMAC", hash: "SHA-256" },
false,
["verify"]
);
const isValid = await window.crypto.subtle.verify(
"HMAC",
key,
signatureBytes,
new TextEncoder().encode(`${headerB64}.${payloadB64}`)
);
B. Asymmetric Signatures (RS256 / ES256)
The authorization server signs the token with a private key, while resource APIs verify it using the public key (or JSON Web Key Set - JWKS). This prevents service backends from being able to forge tokens.
4. The Golden Rule: Never Send Secret Keys Over the Wire
Legacy token inspectors upload your pasted token and secret to external web servers. The MafLabs JWT Decoder executes 100% inside your browser using client-side JavaScript and the Web Crypto API. Your auth tokens, secret keys, and credentials never touch a remote backend.
Decode & Verify JWTs in Your Browser
Inspect header, payload, and expiry claims in real time. Validate HMAC and RSA signatures client-side using Web Crypto with 100% privacy.
Open JWT Decoder →JWT Security Best Practices
- Always enforce strict algorithm checking on your server to prevent the "None algorithm" vulnerability.
- Keep access token lifespans short (15–60 minutes) and use refresh tokens for renewal.
- Never store passwords or sensitive PII inside unencrypted JWT payloads.
- Use MafLabs JWT Decoder to safely inspect tokens without network transmission.