Aller au contenu

decode

Analyse et affiche l’en-tête, les claims et la signature d’un JWT sans vérifier la signature. Pratique pour inspecter rapidement un token, que vous disposiez ou non de la clé de signature.

Par défaut, chaque champ d’en-tête/claim correspondant à un nom JWT enregistré (ex. alg, typ, iss, sub, exp) reçoit une courte description ajoutée en // commentaire en ligne, juste à côté de sa valeur. exp/nbf/iat reçoivent aussi une date lisible et un décalage relatif (« il y a 2 jours »). Si le token possède un claim exp ou nbf, un statut d’une ligne est affiché après la signature indiquant si le token est actuellement expiré, pas encore valide, ou valide.

Terminal window
jwtop decode <token>
echo <token> | jwtop decode
jwtop find --file page.html | jwtop decode
jwtop decode --raw <token>
OptionDescription
--rawN’affiche que le JSON brut et valide de l’en-tête/des claims/de la signature, sans description en ligne ni statut d’expiration. Pratique pour un pipe vers jq ou un autre outil.
Terminal window
jwtop decode eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U

Sortie :

Header:
{
"alg": "HS256", // Algorithm — how the token is signed (or "none")
"typ": "JWT" // Type — media type of the token, typically "JWT"
}
Claims:
{
"sub": "1234567890" // Subject — the principal the token is about
}
Signature:
dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U

Avec --raw, le même token affiche à la place du JSON brut et valide, sans commentaires ni statut d’expiration :

Terminal window
jwtop decode --raw eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U
Header:
{
"alg": "HS256",
"typ": "JWT"
}
Claims:
{
"sub": "1234567890"
}
Signature:
dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U

La commande retourne 1 si le token est structurellement malformé (pas un JWT valide).