Skip to content

Instantly share code, notes, and snippets.

@patro85
Last active June 19, 2022 15:46
Show Gist options
  • Save patro85/2a76d16181730989b9b9af6a7ca6cd1e to your computer and use it in GitHub Desktop.
Save patro85/2a76d16181730989b9b9af6a7ca6cd1e to your computer and use it in GitHub Desktop.
A BBEdit Text Filter script to take textual input and produce decode of JWT tokens.
#!/bin/bash
#
# JWT Decode
# https://gist.github.com/patro85/2a76d16181730989b9b9af6a7ca6cd1e
#
# A BBEdit Text Filter script to take textual input and produce decode of JWT tokens.
# Note: Signature section is ignored. Meant to be used in conjunction with a separate JSON
# formatter.
#
# Installation instructions: Place this file in BBEdit's "Text Filters" folder inside of
# "Application Support" (which will live your ~/Library/, Dropbox, or iCloud Drive)
#
# See https://www.bbeditextras.org/text-filters/
# Patrick Mayo
# @_patrickmayo
# m.patrick.mayo@gmail.com
# April 22, 2022
IN=$(tee)
HEADER="$(echo $IN | cut -d'.' -f1)"
PAYLOAD="$(echo $IN | cut -d'.' -f2)"
CMD1="$(echo -n "$HEADER" | base64 --decode)"
CMD2="$(echo -n "$PAYLOAD" | base64 --decode)"
OUT="$(echo -n "{\"header\":" && echo -n "$CMD1" && echo -n "}," && echo -n "\"payload\":" && echo -n "$CMD2" && echo -n "}")"
echo -n "${OUT}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment