Bash: decoding a JWT from the command line with jq

Although jwt.io has become a common online destination for decoding JWT, this can also be done locally using jq.

# populate JWT variable
JWT=...

# decode with jq utility
echo $JWT | jq -R 'split(".") | .[0],.[1] | @base64d | fromjson'

Attribution of credit goes to this gist.

If you have not installed jq on Debian/Ubuntu, it is offered in the official repositories.

sudo apt install -y jq

For other OS or direct downloads, see the jq official page.

REFERENCES

github.com gist, original gist

prefetch.net, command used in this article

jq downloads/install