Dev.to Security 🔐 Cybersecurity 👁 0 📖 2 min read

Decode JWTs and test regex offline without pasting secrets into online tools

When debugging an auth failure or parsing a production log line, the fastest habit is to paste a JWT, Base64 string, or API payload into the first online formatter in search results. If that payload contains a live sess

When debugging an auth failure or parsing a production log line, the fastest habit is to paste a JWT, Base64 string, or API payload into the first online formatter in search results.

If that payload contains a live session token, internal user ID, email address, or customer data, pasting it into an unknown website means trusting that site's server logs, analytics scripts, and third-party embeds not to record it.

Here are fast ways to do the same work locally, plus a single-file browser toolbox you can run offline with zero network calls.

1. Decode a JWT locally in one terminal command

A JWT is three Base64URL-encoded segments (header.payload.signature). You do not need a website just to read the claims.

Using Python (works on Linux, macOS, and Windows with no extra packages):

python3 -c '
import sys, json, base64
token = sys.argv[1].strip().split(".")
for part in token[:2]:
    padded = part + "=" * (-len(part) % 4)
    print(json.dumps(json.loads(base64.urlsafe_b64decode(padded)), indent=2))
' "YOUR.JWT.TOKEN"

Important: Decoding only reads the header and payload. It does not verify the cryptographic signature. Never trust claims from an unverified token in application logic.

2. Test regex on sensitive logs locally

Instead of pasting customer logs or auth errors into a web regex tester, run a quick local Python snippet that prints every match, index, and capture group:

python3 -c '
import re
pattern = r"(\d+)-(\w+)"
text = "order 1042-paid failed for user_99"
for i, m in enumerate(re.finditer(pattern, text), 1):
    print(f"{i}. {m.group(0)!r} at {m.start()} groups={m.groups()}")
'

3. Use a single-file offline browser toolbox (strict CSP, zero requests)

If you prefer a UI for quick daily formatting and inspection without opening a terminal:

Quick rule of thumb before pasting anywhere

  • Real tokens, cookies, API keys, .env values, and production logs: local terminal or local file:// HTML only.
  • Dummy sample payloads ({"test": 1}): online formatters are fine.

Written by Yogeshwaran Tech Tools. Corrections welcome.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.