skip to content

// security cli

jwt-toolkit

Inspect, compare and stress-test JWTs, with verification you can read.

A Python security CLI for debugging token changes, checking signatures and testing your own verifier. Version 1.1 added token diffs, EdDSA and practical key inputs; 1.2 hardened it after an end-to-end review, so attack-shaped tokens fail verification like any other bad token and the audit grades the key material you supply. Since then token input is bounded and strictly validated, audit can verify against a JWKS, and every finding has a stable rule ID that the explain command describes. The JWS logic stays readable on top of cryptography, without pyjwt or python-jose.

// key08/22
year
2026
type
security cli
group
developer tools
status
released on pypi, maintained

//in plain words

Websites recognise you with a small signed pass called a JWT. jwt-toolkit opens one up, shows what it claims and when it expires, checks whether it was signed safely, compares two of them, and shows a developer how an attacker would try to fake one, so they can make sure their own system refuses it. It runs on your machine and never sends tokens anywhere.

for developers and security testers who need to know what a token really says

the problem

//01the problem

A decoded token can look convincing while its verifier accepts an invalid expiry, ignores a critical header or trusts the wrong algorithm. Debugging those failures also means comparing claims, handling real keys and getting dependable results into CI.

how it works

//02how it works

  1. 01

    Make verification boundaries explicit

    Verification matches algorithm names case-sensitively, rejects unsupported crit headers and non-finite or non-numeric time claims, and expires a token at its exp second. Headers and payloads must be JSON objects. These fixes close acceptance edge cases and turn malformed input into a reported error instead of a crash.

  2. 02

    Explain what changed between tokens

    The diff command walks nested headers and payloads with JSON Pointer paths, highlighting identity, permission and lifetime fields. It preserves array order and JSON types, and distinguishes encoding-only changes from changed claims. JSON output and an optional failure exit code make it useful for regression checks; comparison does not verify either token.

  3. 03

    Work with the keys applications use

    Ed25519, Ed448 and EdDSA join HMAC, RSA, RSA-PSS and ECDSA, including OKP keys from JWKS. X.509 certificates and encrypted private keys reduce key-conversion work. Secret files keep HMAC values out of command arguments, while payload files, relative lifetimes and raw secret output make test fixtures easier to script.

  4. 04

    Crack the candidates you actually supplied

    Wordlist lines retain spaces, leading # characters and non-UTF-8 bytes, so valid candidates are no longer silently changed or skipped. Bounded batches run in worker processes to bypass CPython's GIL, preserving the first match in wordlist order. Small lists avoid process startup costs, and a bundled list makes the command usable immediately after installation.

  5. 05

    Keep security findings honest

    Keyless audits flag risky headers, missing claims and weak configurations; --require now checks every named claim, including custom ones. Forge produces attack-shaped tokens for your own verifier and labels header-only variants whose rejection cannot rule out the named flaw. Untrusted text renders literally, preventing crafted claims from crashing or restyling terminal reports.

  6. 06

    Ship a CLI that automation can trust

    Every --json failure path returns an error document with a stable code. Wordlist downloads stay on verified TLS and use the installed release's tag. Before PyPI publication, the tagged commit must pass tests, coverage, lint, types and security checks, and its tag must match the package version. Trusted Publishing adds distribution attestations.

screens

//03screens

  1. Decoding a token: Header and payload as highlighted JSON, the time claims in UTC and relative to now, and a reminder that decoding checks nothing.
    01Decoding a tokenHeader and payload as highlighted JSON, the time claims in UTC and relative to now, and a reminder that decoding checks nothing.
  2. A keyless audit: An HS256 token graded without its key: the verdict first, then every finding with the field it concerns and what to change.
    02A keyless auditAn HS256 token graded without its key: the verdict first, then every finding with the field it concerns and what to change.
  3. Verify, then a forged copy: One RS256 key accepts the signed token and rejects its alg: none copy, which exits 1 like any other bad signature.
    03Verify, then a forged copyOne RS256 key accepts the signed token and rejects its alg: none copy, which exits 1 like any other bad signature.
  4. What changed between two tokens: Role, scope and lifetime changes by JSON Pointer path, notable ones marked, and --exit-code returning 1 for a CI check. Neither token is verified.
    04What changed between two tokensRole, scope and lifetime changes by JSON Pointer path, notable ones marked, and --exit-code returning 1 for a CI check. Neither token is verified.
  5. Attack-shaped variants: Ten variants to throw at your own verifier, each tied to its CVE where one exists, with the header-only ones labelled because rejecting them proves less.
    05Attack-shaped variantsTen variants to throw at your own verifier, each tied to its CVE where one exists, with the header-only ones labelled because rejecting them proves less.
  6. A weak secret, then a strong one: The bundled wordlist finds changeme at candidate 237 in 4 ms, the command exits 1, and generate-secret prints a 256-bit replacement.
    06A weak secret, then a strong oneThe bundled wordlist finds changeme at candidate 237 in 4 ms, the command exits 1, and generate-secret prints a 256-bit replacement.

measured

//04measured

1,242
passing tests
v1.5.0, pytest in ci on 2 dec 2026, on python 3.13 to 3.15; mypy strict is part of the gate
97.21%
test coverage
same run, statements and branches; startup banner excluded
15
signing algorithms
hmac, rsa, rsa-pss, ecdsa and eddsa families; none is never accepted
11
pypi releases
25 may to 2 dec 2026, published through trusted publishing

decisions

//05decisions

  1. 01

    chose re-implementing JWS on top of cryptography

    over pyjwt or python-jose

    Showing how signing works and where it breaks is the point of the tool, so the signature check has to be readable. The cost is owning every edge case, which is why the verifier's rules are written down and tested one by one.

  2. 02

    chose the algorithm family from the key you supply

    over the alg header in the token

    Trusting the header is the classic confusion attack: an RSA public key accepted as an HMAC secret. The key decides the family, and alg none is never accepted.

  3. 03

    chose labelling header-only forge variants

    over reporting every rejection as a pass

    If a verifier rejects a token with a tampered kid, that does not prove it is safe from kid injection; it may have failed for another reason. The report says which variants prove nothing by themselves.

  4. 04

    chose stable error codes and an additive JSON schema

    over free-form messages

    A CI gate needs to match on a code that will still exist next year. Codes are frozen and the JSON shape only ever gains fields.

try it

//06try it

  1. //install with pipx or uv

    pipx install jwt-toolkit

    python 3.13 or later; uv tool install jwt-toolkit also works

  2. //try it without installing

    uvx jwt-toolkit audit "$TOKEN"
  3. //gate a pipeline on a token's shape

    jwt-toolkit --quiet audit "$SERVICE_TOKEN" --strict --require iss,aud,exp --json > audit.json

    exit 0 clean, 1 findings, 2 unreadable

highlights

//07highlights

  • Eleven PyPI releases since May 2026, installable with pipx or uv
  • Token diffs with JSON Pointer paths and CI exit codes
  • EdDSA, JWKS, certificates and encrypted private keys
  • UTC and relative timestamps for decoded time claims
  • Bundled wordlist and bounded process-based cracking
  • Stable JSON errors and a validated PyPI publishing workflow

built with

  • Python
  • cryptography
  • Click
  • Rich
  • PyPI

on githubjwt-toolkit

stars
4
license
MIT
language
Python
latest release
v1.5.0 dec 2, 2026
last push
dec 2, 2026

printings

//08printings

  1. v0.1.0

    Decode, sign, verify with JWKS, audit, forge, crack, generate-secret and download-wordlists, published to PyPI the day after the first commit.

  2. v1.0.0

    First stable release with the public surface unchanged since 0.1.3 and the dependency advisories cleared.

  3. v1.1.0

    The diff command, EdDSA, secret and payload files, certificates and encrypted keys, the bundled wordlist with worker processes, stricter verification and stable JSON errors.

  4. v1.2.0

    Hardening from an end-to-end review: alg none, mis-cased and cross-family algorithms now fail verify with exit 1 like any bad signature; audit grades guessable secrets, short HMAC keys and RSA under 2048 bits; crack gains JSON output, Bearer prefixes are accepted everywhere, and errors go to stderr. No JSON field renamed, no new dependency.

  5. v1.2.1

    Malformed tokens are rejected on Python 3.15, which stopped rejecting characters outside the base64 alphabet, and download-wordlists works on Windows. CI now tests CPython 3.13, 3.14 and 3.15 on Linux and Windows, plus 3.13 on macOS.

  6. v1.4.0

    Audit verifies signatures against a JWKS through one core verifier, and token input is bounded and strictly validated. Version 1.3.0 the same day added a specific cause next to broad JSON error codes and stopped credentials in source URLs from being echoed.

  7. v1.5.0

    Stable rule IDs for audit findings, a rule catalogue and the explain command, plus published JSON Schemas and a written stability contract.

questions

//09questions

Does decode verify the token?
No. Decode and diff show what a token says without checking the signature. Use verify with the right key before trusting the contents.
Is it safe to run crack?
Only on tokens you own. It exits 1 when the secret is found, and not finding one with a wordlist does not prove the secret is strong.
How do I keep secrets out of my shell history?
Pass them as files with --secret-file, and generate new ones with generate-secret --raw straight into a file.
Does it send tokens anywhere?
No. The only network calls are fetching a JWKS you point it at and downloading wordlists over verified TLS. Tests never touch the network.

related sheets

//10related sheets

//11contact

Say hello.I read everything.

Email is the fastest way to reach me. For anything that needs a conversation, book a call.

to

name
Khaled Saeed
country
Lebanon