javascript
function decodeJwt(token) {
var base64Payload = token.split(".")[1];
var payloadBuffer = Buffer.from(base64Payload, "base64");
return JSON.parse(payloadBuffer.toString());
}
Usage
var payload = decodeJwt(
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
);
console.log(payload);