@chengyixu/jwt-decode-cli
v1.0.0
Published
Decode and inspect JWT tokens from the terminal. View header, payload, expiry, and more.
Maintainers
Readme
jwt-decode-cli
Decode and inspect JWT tokens from the terminal. No external dependencies.
A fast, zero-dependency CLI tool to decode JSON Web Tokens (JWTs). Inspect headers, payloads, expiry status, and claim details — all from your terminal.
Install
npm install -g jwt-decode-cliOr run without installing:
npx jwt-decode-cli <token>Usage
# Pass token directly
jwt-decode eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
# Pipe from stdin
echo "eyJhbGci..." | jwt-decode
cat token.txt | jwt-decode
# Show help
jwt-decode --help
# Note signature verification requirement
jwt-decode <token> --verify
# Raw JSON output (no formatting)
jwt-decode <token> --rawOutput
━━ Header ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
{
"alg": "HS256",
"typ": "JWT"
}
━━ Payload ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
{
"sub": "1234567890",
"name": "John Doe",
"iat": 1516239022
}
━━ Signature ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
━━ Time Analysis ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
iat (issued at): 2018-01-18 01:30:22 UTC (7y 2m ago)
exp: ⚠ No expiry set — token never expires
━━ Claims Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
sub (subject): 1234567890
custom claims: nameFeatures
- Zero dependencies — uses only Node.js built-ins
- Colored output — syntax-highlighted JSON, color-coded expiry status
- Expiry detection — shows time until expiry or how long since expired
- Stdin support — pipe tokens from other commands
- Claims summary — highlights standard JWT claims (iss, sub, aud, jti, etc.)
- Raw JSON mode —
--rawfor scripting/piping tojq - Expired token warning — bold red banner when token is expired
--verifyflag — placeholder with guidance for signature verification
Flags
| Flag | Description |
|------|-------------|
| --verify | Notes that verification requires a secret/public key, provides guidance |
| --raw | Output raw JSON (no colors or formatting) |
| --no-color | Disable colored output (or set NO_COLOR env var) |
| --help, -h | Show help |
Examples
# Decode a token from an environment variable
jwt-decode $JWT_TOKEN
# Check token expiry in a script
jwt-decode $TOKEN --raw | jq '.payload.exp'
# Decode token stored in a file
cat ~/.config/token | jwt-decode
# Use in CI/CD to inspect tokens
echo $GITHUB_TOKEN | jwt-decodeSecurity Note
This tool decodes JWTs but does not verify the signature. It is intended for development, debugging, and inspection purposes. Never trust a JWT's claims without verifying the signature using the appropriate secret or public key.
For signature verification, use:
- jsonwebtoken npm package
- jwt.io (web-based debugger)
License
MIT © chengyixu
