Skip to content

Instantly share code, notes, and snippets.

@pancudaniel7
Last active February 25, 2025 15:21
Show Gist options
  • Save pancudaniel7/39461fedbbb7930906b3734dcef7f9a5 to your computer and use it in GitHub Desktop.
Save pancudaniel7/39461fedbbb7930906b3734dcef7f9a5 to your computer and use it in GitHub Desktop.
Decode JWT + convert timestamp to date
# You can add this to your .bashrc or .zshrc
function decode_jwt {
echo "$1" | jq -R '
split(".") |
.[1] |
gsub("-"; "+") | gsub("_"; "/") | @base64d |
fromjson |
(if .iat then .iat = (.iat | todate) else . end) |
(if .exp then .exp = (.exp | todate) else . end)
'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment