Skip to content

Instantly share code, notes, and snippets.

@jforge
Forked from angelo-v/jwt-decode.sh
Created June 12, 2024 11:30
Show Gist options
  • Save jforge/c4d6c3d744a3d91dce6b2c5458f67ec7 to your computer and use it in GitHub Desktop.
Save jforge/c4d6c3d744a3d91dce6b2c5458f67ec7 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