cd /news/ai-tools/scrubbing-api-keys-jwts-and-pii-befo… · home › topics › ai-tools › article
[ARTICLE · art-177674] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

Scrubbing API Keys, JWTs, and PII Before Pasting Logs into AI Chats (100% Client-Side)

A developer built a free, fully client-side redactor that scrubs API keys, JWTs, private keys, and PII from logs before they are pasted into AI chats such as ChatGPT or Claude. The tool maps each unique (category, value) pair to an indexed placeholder like [EMAIL_1] so LLMs can still trace relationships across lines, orders provider-specific signatures before generic rules, and filters card-number candidates through a Luhn checksum to cut false positives. It runs entirely in the browser with no network requests.

recommendation

Redact secrets client-side before pasting logs into AI chats: order provider-specific signatures first, use indexed placeholders, and gate card-number matches through a Luhn check.

more in playbook: Securing agents and AI tools
by read2 min views5 publishedNov 28, 2026

Every developer has had the same split-second hesitation before hitting Ctrl+V into ChatGPT, Claude, or an AI coding prompt: does this stack trace, .env snippet, or HTTP header still contain a live token, database password, or customer email?

Up sensitive logs to an online "sanitizer" hosted on someone else's server defeats the entire point of redacting them. A clean sanitizer belongs 100% inside the browser with zero network requests and deterministic placeholders so the LLM still understands relationships across lines.

Here is the exact client-side pipeline behind our free AI Prompt Secret & PII Redactor.

Replacing every secret with *** breaks debugging when you need an LLM to compare two tokens or trace why user_a failed while user_b succeeded. Mapping each unique (category, rawValue) pair to an indexed placeholder keeps structure intact:

function makeTokenizer() {
  const seen = new Map();
  const counters = {};

  return function tokenFor(label, value) {
    const key = `${label}\0${value}`;
    if (seen.has(key)) return seen.get(key);
    counters[label] = (counters[label] || 0) + 1;
    const tok = `[${label}_${counters[label]}]`;
    seen.set(key, tok);
    return tok;
  };
}

If alex@acme.dev appears three times in a log, all three occurrences become [EMAIL_1], while a second address becomes [EMAIL_2].

If a generic KEY=value rule runs before provider-specific rules, an OPENAI_API_KEY=sk-proj-... line gets tagged generically or loses prefix context. Ordering specific signatures first keeps detections accurate:

-----BEGIN ... PRIVATE KEY-----) postgres://user:pass@host) eyJ... . eyJ... . ...) sk-ant-), OpenAI ( sk-proj- / sk-), GitHub ( ghp_, github_pat_), AWS ( AKIA/ ASIA), Stripe ( sk_live_/ rk_live_), Slack ( xoxb-), Google ( AIza...) Authorization: Bearer [BEARER_TOKEN_1], SECRET_KEY=[ENV_SECRET_1]) Long order IDs, Unix nanosecond timestamps, and trace IDs constantly trigger naive \d{13,19} card regexes. Filtering candidates through a 12-line Luhn checksum eliminates almost all false positives:

function passesLuhn(digits) {
  let sum = 0;
  let dbl = false;
  for (let i = digits.length - 1; i >= 0; i--) {
    let n = digits.charCodeAt(i) - 48;
    if (dbl) {
      n *= 2;
      if (n > 9) n -= 9;
    }
    sum += n;
    dbl = !dbl;
  }
  return sum % 10 === 0;
}
── more in #ai-tools 4 stories · sorted by recency
── more on @chatgpt 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/scrubbing-api-keys-j…] indexed:0 read:2min 2026-11-28 · —