Simple, fast, and efficient tool for decoding, editing, auditing, and verifying JWT tokens, fully offline.
jwt is a small terminal tool for working with JWT tokens. It decodes tokens, checks them for common security issues, and verifies signatures. Everything runs locally, so tokens never leave your machine.
- Decode tokens from args, files, pipes, and logs.
- Tolerant input.
Bearerprefixes, quotes, and extra whitespace are stripped automatically. - Output modes for humans and scripts:
pretty,json,compact,table. - Single claim lookup with
--claim. - Passive security audit with severity levels and CI gates.
- Signature verification for HMAC, RSA, ECDSA, and EdDSA, with JWKS support.
- Live token editor with
jwt tui: edit header and payload, watch the encoded token and audit update, sign HMAC tokens, copy the result, and move with Vim-stylectrl+h/j/k/lmotions. - Stable exit codes for scripts and CI.
To install the jwt tool, you can simply use the following command.
go install -v "github.com/yourpwnguy/jwt/v2/cmd/jwt@latest"
cp ~/go/bin/jwt /usr/local/bin/jwt [command] [options] [token]
Commands:
decode Decode tokens (default when no command is given)
audit Passive security checks, no network, no secrets
verify Check signature and exp, nbf, aud, iss
tui Live token editor, interactive
version Print version and exit
Decode examples:
jwt -t <token> decode one token
jwt <token> same, positional
echo $TOKEN | jwt pipe
curl -s api | jq -r .token | jwt
jwt -tL tokens.txt batch file, one token per line
cat app.log | jwt --extract find tokens hidden in logs
jwt $TOKEN -o json | jq .payload
jwt $TOKEN --claim sub print one claim, useful for scripts
jwt -tL list -o table batch overview
Audit examples:
jwt audit <token> human readable triage
jwt audit -tL list -o json | jq
jwt audit <token> --fail-on high exit 2 when high or critical findings exist
Verify examples:
jwt verify <token> --secret s3cr3t
jwt verify <token> --pubkey @key.pem --aud api --iss auth.example.com
jwt verify <token> --jwks https://auth.example.com/.well-known/jwks.json
Editor examples:
jwt tui <token> edit with live encoding and audit
echo $TOKEN | jwt tui edit a piped token
jwt tui -f token.txt edit one token from a file
jwt tui start from a blank token
Options (decode):
-t <token> single token
-tL <file> file with one token per line
--extract scan text for embedded tokens
-o, --format pretty, json, compact, table (default pretty)
--H header only
--P payload only
--claim a.b.c single claim by dot path
-q, --quiet just data, no Token headers or status line
--no-color plain output
--verify-exp exit 2 when expired or not yet valid
--leeway 30s clock skew toleranceNotes:
Flags can go before or after the token. Errors go to stderr, so stdout
stays clean for piping into jq. Exit codes are 0 for success, 1
for system errors such as bad flags or unreadable files, and 2 for
validation failures such as an expired token or a breached audit gate.
$ jwt -t "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
● HS256 · sub 1234567890 · ! no exp claim (never expires)
{
"header": {
"alg": "HS256",
"typ": "JWT"
},
"payload": {
"iat": 1516239022,
"name": "John Doe",
"sub": "1234567890"
},
"signature": "SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}The first line is a summary with the algorithm, subject, and expiry status. The full JSON follows below it.
$ jwt -t "$TOKEN" --claim sub
1234567890$ jwt audit -t "$TOKEN"
✗ FAIL 1/8 · fail-on high
────────────────────────────────────────────────────
✗ HIGH missing-exp no exp claim, stolen tokens never expire
────────────────────────────────────────────────────
✓ none-alg · weak-alg · long-lived · jku-x5u · kid · sensitive-claim · time-skew (7 passed)8 checks ran, 1 failed. This token has no expiry, so a stolen token stays valid indefinitely.
As a CI gate, it fails the build on high or critical findings:
$ jwt audit -t "$TOKEN" --fail-on high
$ echo $?
2$ jwt verify -t "$TOKEN" --secret "your-256-bit-secret"
✓ Signature: VALID · HS256
✓ Claims: VALID
────────────────────────────────────────
{
"header": {
"alg": "HS256",
"typ": "JWT"
},
"payload": {
"iat": 1516239022,
"name": "John Doe",
"sub": "1234567890"
},
"signature": "SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}$ jwt tui "$TOKEN"JWT ●●● token studio HS256 UNTOUCHED ✗ 1 ISSUE
● HEADER ○ PAYLOAD ○ SIGNATURE exact bytes · no re-marshal
╭──────────────────────────────────────────────────────────────╮ ╭────────────────────────────────────────────────────╮
│ 1 { │ │ ENCODED TOKEN 155 B │
│ 2 "alg": "HS256", │ │ │
│ 3 "typ": "JWT" │ │ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxM │
│ 4 } │ │ jM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE │
│ │ │ 2MjM5MDIyfQ. │
│ │ │ SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c │
│ │ │ │
│ │ │ ────────────────────────────────────────────────── │
│ │ │ signature untouched │
│ │ │ alg HS256 │
│ │ │ exp no exp claim (never expires) │
│ │ │ size 155 B │
│ │ │ │
│ │ │ ────────────────────────────────────────────────── │
│ │ │ PROPERTY alg │
│ │ │ Signing algorithm. HS256/384/512 share a secret; │
│ │ │ RS/PS/ES/EdDSA use a key pair. │
│ │ │ type string · value "HS256" │
│ │ │ │
│ │ │ ────────────────────────────────────────────────── │
│ │ │ AUDIT ✗ 1 issue │
│ │ │ ✗ HIGH missing-exp │
│ │ │ no exp claim, stolen tokens never expire │
│ │ │ ✓ 7 checks passed │
│ │ │ none-alg · jku-x5u · weak-alg · long-lived · kid · │
╰──────────────────────────────────────────────────────────────╯ ╰────────────────────────────────────────────────────╯
NORMAL hjkl move · w/b words · 0/$ ends · f{char} find · i edit · : command · ? help
The editor is a live scratchpad. Header and payload are plain JSON, the token inspector always shows the exact encoded bytes, and the audit summary updates as you type. The three section colors still come from the logo: amber header, coral payload, cyan signature.
This is the first token studio layout: cards on wide terminals, stacked editor and token on narrow ones. The page paints no background, so the terminal background shows through. Filled pills are reserved for status and the active tab; the editor itself is plain text inside a hairline card.
| Key | Action |
|---|---|
arrows |
Move the cursor, always available |
ctrl+h / ctrl+j / ctrl+k / ctrl+l |
Move while editing |
h / j / k / l |
Move in normal mode |
w / b |
Next / previous word |
0 / $ |
Start / end of line |
f{char} / ; |
Find / repeat find |
gg / G |
First / last line |
i / enter |
Insert at the cursor |
a |
Append after the cursor |
o / O |
Open a line below / above and insert |
c{motion} |
Change: cw, cb, c$, cc |
d{motion} |
Delete: dd, dw, diw, daw |
s |
Change character |
tab / shift+tab |
Next / previous section |
ctrl+o or esc |
Return to normal mode |
1 / 2 / 3 |
Header / payload / signature (normal mode) |
y |
Copy the encoded token (normal mode) |
? |
Help (normal mode) |
: |
Command line: :sign, :audit, :token, :format, :compact, :help, :q |
ctrl+s |
Sign the token |
ctrl+y |
Copy the encoded token |
ctrl+c |
Quit from anywhere |
The motions are on by default. ctrl+i is the Tab key at the terminal level, so it cannot be distinguished from Tab, and Tab keeps switching sections. ctrl+h and ctrl+k would otherwise be the textarea's delete aliases; Backspace and Delete still delete. If you would rather avoid the insert-mode control motions, start with jwt tui --no-vim-keys. Normal mode still uses plain h/j/k/l, because those are ordinary characters.
The editor starts in normal mode, exactly like Neovim. i or enter begins editing at the static block cursor; esc or ctrl+o returns to normal. ctrl+o is a single control key, so it is handy if a very fast esc looks like an Alt sequence to your terminal. App actions moved to the : line so c, f, s, a, and v stay free for editing.
In insert mode, the JSON editors auto-close quotes, braces, brackets, and parentheses, leaving the cursor between the pair. Typing the closing character again steps over it. The inspector card also explains the key on the cursor line, or the nearest key above a bare value line, so alg, exp, aud, kid, and custom claims are documented while you move.
The Signature tab is editable. You can paste a base64url signature produced by another tool. If the header or payload changes after a signature, the status turns STALE and copying warns you. ctrl+s or :sign re-signs HMAC tokens with the secret you enter. Asymmetric signing is not in this build, so RS, PS, ES, and EdDSA tokens can still be edited, audited, and copied, but their signature will be marked stale until you paste or generate a new one.
The editor never rewrites a token silently. Untouched panes keep their original base64 segments, and edited panes encode the exact text on screen, including whitespace and duplicate keys. That matters when you are testing how different parsers treat the same token. The editor shows pretty JSON, but the inspector token is the real bytes.
Copy prefers a native clipboard tool: wl-copy, xclip, xsel, pbcopy, or clip. Over SSH, or when no native tool is available, it falls back to OSC 52 so the terminal can hand the token to the local clipboard. The token is passed on stdin, not as a process argument. Secrets and tokens stay in memory and are not written to disk. Use --theme auto|dark|light if the terminal detects the background wrong, --no-color for a plain UI, and --no-vim-keys to turn off the insert-mode ctrl+h/j/k/l motions.
The TUI is built with Bubble Tea, Bubbles, and Lip Gloss. They are pinned to versions that keep the project's Go 1.21 minimum. The core decode, audit, and verify paths do not change.
This part covers what happens under the hood. The quick start above is enough to use the tool. Everything below is the reasoning behind it.
The goal is a tool for terminals, where tokens actually live. API responses, log files, CI pipelines. That shaped most of the decisions here.
Seeing what is inside a token and trusting a token are different things, so the code keeps them apart. internal/jwt only decodes, with no crypto and no network. internal/verify handles trust decisions and is the only place that checks a signature or fetches keys. internal/secret owns secret loading, and internal/sign computes HMAC signatures for the editor. The audit package only reads structure. It takes no secrets and makes no network calls, so it is safe to run on dumps that are not trusted yet.
Tokens arrive messy in practice. Bearer prefixes from headers, quotes from JSON, stray whitespace. The input layer strips all of that without complaining. Once the string is clean, parsing is strict. Three parts, base64url, JSON objects. Errors say which part broke.
Every command has a human mode and a machine mode. Pretty output has status lines, symbols, and colors. JSON and compact output have none of that, so jwt -o json | jq always works. Errors go to stderr for the same reason.
The TUI does not decode JSON, change the key order, and re-encode it. Untouched panes keep the original base64 segments from the token you opened. The pane you edit is encoded from the exact text on screen. If a token arrives with unusual whitespace, or even duplicate keys, the untouched panes still encode to the same bytes. That is useful when two services disagree about what a token says.
The visible JSON is pretty-printed for editing, but that view is not the source of truth for the token. The encoded pane is. The signature status is equally literal: UNTOUCHED means loaded and not modified, SIGNED means this session computed it, STALE means the header or payload changed after signing, and UNSIGNED means there is no signature or alg is none. The editor never calls a signature valid without a key.
0 means success. 1 means a system error, such as bad flags or an unreadable file. 2 means validation failed, such as an expired token or a breached audit gate. The TUI follows the same rule: quitting normally is 0, a missing terminal or launch failure is 1.
The code is split into small packages, each with a clear boundary:
cmd/jwtis the thin entry point. It wires stdio and signals, then hands off.internal/cliowns flags, subcommands, and exit codes. No JWT logic lives here.internal/jwtowns decoding and claim helpers. No network, no crypto.internal/inputowns where tokens come from. Args, files, stdin, Bearer stripping, extraction.internal/outputowns rendering. The only place that prints to stdout.internal/auditowns the passive security rules. Pure functions, safe for concurrent use.internal/verifyowns signatures and claims. The only place that checks trust or fetches keys.internal/signcomputes HMAC signatures for the editor. No trust decisions.internal/secretloads HMAC secrets and rejects PEM key material, so verify and the editor share one confusion guard.internal/tuiowns the interactive editor. Rendering and keyboard flow only.internal/readerandinternal/versionare tiny helpers for files and version info.
jwt.io works well for a quick look at a single token. But production tokens should not be pasted into websites, and a browser cannot grep logs or fail builds. This tool runs locally, handles thousands of tokens at once, and fits into existing pipes. The TUI keeps the same rule: you can edit and re-sign a token without it leaving your machine.
Tools like jwt-cli and jwt-hack cover similar ground. This one prioritizes clean boundaries and reliability over feature count. Decode, edit, audit, and verify answer different questions, so they stay separate.
Contributions are welcome. If you have suggestions, bug reports, or feature requests, feel free to open an issue or submit a pull request. The codebase is small on purpose, so it is easy to follow where a change should go.
