pipr.tools

jwt-decode

Decode a JWT token (no verification)

{ } Encode

Try it

stdin0 chars
stdout0 chars

Example

Decode a JWT to inspect header and payload

Usage
$ echo "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODk..." | jwt-decode
View source
(input) => {
      try {
        const parts = input.trim().split(".");
        if (parts.length < 2) return "Error: not a valid JWT";
        const header = JSON.parse(
          atob(parts[0].replace(/-/g, "+").replace(/_/g, "/")),
        );
        const payload = JSON.parse(
          atob(parts[1].replace(/-/g, "+").replace(/_/g, "/")),
        );
        return JSON.stringify({ header, payload }, null, 2);
      } catch (e) {
        return `Error: ${e.message}`;
      }
    }

Suggested Pipelines

Related Tools