HomeBlogHow to Decode JSON Web Tokens (JWT) Locally and Safely
Security4 min read

How to Decode JSON Web Tokens (JWT) Locally and Safely

AV
Alex Vance
Identity Architect • Published May 18, 2026
Back to Insights

JSON Web Tokens (JWTs) are the standard protocol for stateless session management. However, because they are Base64URL-encoded, developers often use public decoder sites to view the claims inside them.

This is highly insecure. A JWT contains user roles, scopes, emails, and sometimes even secrets. If a third-party site logs these tokens, they could potentially hijack active sessions.

Decoding Safely

You can easily decode a JWT payload locally in your browser console using vanilla JavaScript:

function decodeJWTPayload(token) {
  const parts = token.split('.');
  if (parts.length !== 3) {
    throw new Error('Invalid JWT format');
  }
  const payloadBase64 = parts[1].replace(/-/g, '+').replace(/_/g, '/');
  const jsonPayload = decodeURIComponent(
    atob(payloadBase64)
      .split('')
      .map(c => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2))
      .join('')
  );
  return JSON.parse(jsonPayload);
}

Our JWT Decoder tool automates this process completely on the client side, showing header, payload, and signature integrity checks instantly and privately.

Share this security insight:

Related Insights

Secure JSON Formatter Online: Format & Validate JSON Privately
Privacy

Secure JSON Formatter Online: Format & Validate JSON Privately

5 min read
Preventing Regular Expression Denial of Service (ReDoS) Attacks
Security

Preventing Regular Expression Denial of Service (ReDoS) Attacks

6 min read
Why Offline-First Web Tools are the Future of Developer Productivity
Dev Tools

Why Offline-First Web Tools are the Future of Developer Productivity

3 min read