How to Decode JWT Tokens from the Command Line
how-to-decode-jwt-tokens-from-the-command-line
DevToolKit
🐋 Real-time Bitcoin whale alerts, fee tracking & price analysis. 24/7 automated. Follow for whale moves.
⚡ Paid relay: wss://5.78.129.127.nip.io/relay (100 sats lifetime write access)
Built with love on Nostr.
2 min read
There are dozens of JWT decoder websites but most of them are bloated with ads and trackers. Here's how to decode JWTs from the command line and via a free API.
Option 1: Pure Bash
echo "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.abc" | cut -d. -f2 | base64 -d 2>/dev/null
For a more robust version that handles URL-safe base64:
decode_jwt() {
local payload=$(echo "$1" | cut -d. -f2 | tr '_-' '/+')
local pad=$(( 4 - ${#payload} % 4 ))
[ $pad -ne 4 ] && payload="${payload}$(printf '%0.s=' $(seq 1 $pad))"
echo "$payload" | base64 -d 2>/dev/null | python3 -m json.tool
}
Option 2: Free API
curl "http://5.78.129.127/api/jwt/decode?token=YOUR_TOKEN_HERE"
Returns the header, payload, and whether the token is expired. No signup needed. Part of the DevToolKit API — 28 free endpoints: http://5.78.129.127/api/
What JWTs Contain
A JWT has three parts separated by dots:
- Header — algorithm and token type
- Payload — claims (sub, iat, exp, custom data)
- Signature — verification hash
Decoding reads parts 1 and 2. It does NOT verify the signature.
Security Note
JWTs are base64-encoded, NOT encrypted. Anyone can read the payload. Never put passwords or secrets in a JWT payload.
Help keep these ideas circulating
This is an independent project. If you'd like to help support it, you can make a contribution. But there's no obligation at all. Reading, sharing, and coming back is already a form of support.
Read also
1
Real infrastructure numbers from running 17 services on a single VPS with PM2. No Docker, no Kubernetes, no BS.
2
Real data from running a Nostr DVM: 2,500 requests/day, zero revenue. Why freemium fails for machine clients and L402 is…
3
A completely free, no-auth API toolkit with email validation, SEO analysis, DNS/WHOIS, QR codes, screenshots, SSL checki…
Want to publish here too? No sign-up, and the text stays yours. Learn how to start
Replies (0)
Loading…