Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jwt-decode (CLI)

Zero dependencies Node License: MIT Platform

Decode and inspect a JWT from your terminal — header, claims, and human-readable expiry. Zero dependencies.

The safe alternative to pasting tokens into jwt.io: this runs entirely locally, so your token never leaves your machine.

Installs the jwt-decode command. (npm package name is jwt-decode-cli because jwt-decode is an existing library.)


Install

npm install -g jwt-decode-cli

Or without installing:

npx jwt-decode-cli <token>

Usage

jwt-decode eyJhbGciOiJ...           # Decode a token
jwt-decode -f token.txt             # Read from a file
echo "$TOKEN" | jwt-decode -        # From stdin / clipboard
jwt-decode "$TOKEN" --payload       # Just the claims (JSON)
jwt-decode "$TOKEN" --json          # Full header+payload as JSON

A leading Bearer (as copied from an Authorization header) is stripped automatically.


Example Output

jwt-decode

  Header
    alg                   "HS256"
    typ                   "JWT"

  Payload
    sub                   "1234567890"          subject
    name                  "Alice"               name
    iat                   1716200000  → 2024-05-20T10:13:20.000Z   3d ago
    exp                   1716203600  → 2024-05-20T11:13:20.000Z   EXPIRED 3d ago

  Signature
    present               SflKxwRJSMeKKF2QT4fw…   43 chars
    not verified — this tool only decodes

  ● Token is EXPIRED

What It Shows

  • Header — algorithm and type, with a warning if alg=none (unsigned).
  • Payload — every claim, with standard claims annotated (iss, sub, aud, …).
  • Time claimsexp, iat, nbf are converted to ISO timestamps and a relative time (expires in 2h, EXPIRED 3d ago).
  • Signature — whether one is present and how long it is.
  • Validity — a one-line verdict: valid window / expired / not-yet-valid.

⚠ Decode ≠ Verify

This tool decodes a token — it does not verify the signature. Anyone can craft a token with any claims. Never make authorization decisions based on an unverified token; always verify the signature server-side with your secret/public key.


Options

Flag Description
-f, --file <path> Read the token from a file
--json Output header + payload as JSON
--payload Print only the payload
--header Print only the header
--raw No color or annotations

License

MIT


Keywords

jwt decoder · decode jwt · jwt.io alternative · inspect token · jwt offline · bearer token · json web token · token expiry · zero dependencies · cli


Built to solve, shared to help — Rushabh Shah 🛠️✨

One of 40+ zero-dependency developer CLI tools — no node_modules, ever.

Releases

Packages

Contributors

Languages