Skip to content

diff

Compare a base JWT against one or more other JWTs and report which header fields, claims, and the signature differ. Useful for spotting unexpected drift between two tokens — e.g. before/after a re-signing step, or comparing tokens issued for different users/environments.

Terminal window
jwtop diff <base-token> <other-token> [<other-token>...]
jwtop find --file page.html | jwtop diff

The first token is the base; every subsequent token is diffed against it. Tokens can be passed as positional arguments, or piped one per line via stdin when fewer than two are given as arguments — this lets diff compose directly with find.

FlagDescription
--formatOutput format: text (human-readable, default) or json (machine-readable, for scripts/CI)

Human-readable (default)

Terminal window
jwtop diff $OLD_TOKEN $NEW_TOKEN

Output:

Base: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
--- Token 1: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Claims:
- iat: 1516239022
- name: "John Doe"
+ role: "admin"
Signature: changed

Each changed field is prefixed + (added on the compared token), - (removed), or ~ (value changed, shown as old -> new). A token that matches the base exactly prints (identical).

Machine-readable, for scripts

Terminal window
jwtop diff $OLD_TOKEN $NEW_TOKEN --format json | jq '.diffs[0].claims'

The JSON shape:

{
"base": "<base token>",
"diffs": [
{
"token": "<compared token>",
"header": [{ "key": "alg", "status": "changed", "base": "HS256", "other": "RS256" }],
"claims": [{ "key": "role", "status": "added", "other": "admin" }],
"signatureChanged": true,
"identical": false
}
]
}

status is one of added, removed, or changed. base/other are omitted where not applicable (e.g. base is absent for an added field).

Compare every token found in a captured response

Terminal window
curl -s https://api.example.com/profile | jwtop find | jwtop diff
CodeMeaning
0Every compared token is identical to the base
1At least one compared token differs from the base, or an argument/format error occurred