Skip to content

Instantly share code, notes, and snippets.

@akkerman
Created March 11, 2022 07:19
Show Gist options
  • Save akkerman/7ee509df1d5ed3248c613a667f7346bb to your computer and use it in GitHub Desktop.
Save akkerman/7ee509df1d5ed3248c613a667f7346bb to your computer and use it in GitHub Desktop.
Decode a Json Web Token and add dates that a human understands.
#!/usr/bin/env node
const jwt = require('jsonwebtoken')
const token = jwt.decode(process.argv[2])
const output = {
token,
issued: new Date(1000*token.iat).toLocaleString(),
expires: new Date(1000*token.exp).toLocaleString(),
}
console.log(JSON.stringify(output, null, 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment