Gist | Install Decode JWT is too slow to load for me. This is instant!

  • Extracts out the token from the entered string and then decodes it.
  • Provides live hint of entered string if contains valid token or not.

// Menu: Decode JWT
// Description: Enter any string which contains valid jwt.
// Author: Ravi Sharma
// Twitter: @irvisharma
/** @type typeof import("jsonwebtoken") */
const jwt = await npm('jsonwebtoken');
try {
const dirtyEncodedToken = await arg('Paste token here', generateLiveHint);
const decoded = decodeToken(dirtyEncodedToken)
if (decoded === null) {
throw 'cannot parse, invalid token'
} catch (e) {
function decodeToken(dirtyEncodedToken){
const extractedToken = dirtyEncodedToken.match(/[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*/)[0]
return jwt.decode(extractedToken);
} catch (e) {
return null;
async function generateLiveHint(userInput){
const tokenValidHint = decodeToken(userInput) !== null ? '✅ Found valid token' : `❌ Could not parse <br><br> ${userInput}`;
return md(`
_Press enter after entering to token show details_
${userInput && tokenValidHint}
function showOutput(value) {
return show(`
<pre style="font-family: Menlo; background: darkslategray; color: navajowhite; font-size: 1.2rem; padding: 1.5em;">
${JSON.stringify(value, null, 2)}
function showError(e){
<h1 style="background: darkslategray; color: white; font-family: Menlo;">Could not decode, Did you entered valid token? <br/><br/> ${e}</h1>