Skip to content

Instantly share code, notes, and snippets.

@abuxton
Forked from angelo-v/jwt-decode.sh
Created December 1, 2020 14:28
Show Gist options
  • Save abuxton/9531da4cda7e2d71d377c3a493b05973 to your computer and use it in GitHub Desktop.
Save abuxton/9531da4cda7e2d71d377c3a493b05973 to your computer and use it in GitHub Desktop.
Decode a JWT via command line
# will not work in all cases, see https://gist.github.com/angelo-v/e0208a18d455e2e6ea3c40ad637aac53#gistcomment-3439904
function jwt-decode() {
sed 's/\./\n/g' <<< $(cut -d. -f1,2 <<< $1) | base64 --decode | jq
}
JWT=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ
jwt-decode $JWT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment