{"slug": "scrubbing-api-keys-jwts-and-pii-before-pasting-logs-into-ai-chats-100-client", "title": "Scrubbing API Keys, JWTs, and PII Before Pasting Logs into AI Chats (100% Client-Side)", "summary": "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.", "body_md": "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?*\n\nUploading 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.\n\nHere is the exact client-side pipeline behind our free [AI Prompt Secret & PII Redactor](https://larkandlever.github.io/tools/pii-redactor/).\n\nReplacing 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:\n\n``` js\nfunction makeTokenizer() {\n  const seen = new Map();\n  const counters = {};\n\n  return function tokenFor(label, value) {\n    const key = `${label}\\0${value}`;\n    if (seen.has(key)) return seen.get(key);\n    counters[label] = (counters[label] || 0) + 1;\n    const tok = `[${label}_${counters[label]}]`;\n    seen.set(key, tok);\n    return tok;\n  };\n}\n```\n\nIf `alex@acme.dev` appears three times in a log, all three occurrences become `[EMAIL_1]`, while a second address becomes `[EMAIL_2]`.\n\nIf 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:\n\n`-----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]`)\nLong 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:\n\n``` js\nfunction passesLuhn(digits) {\n  let sum = 0;\n  let dbl = false;\n  for (let i = digits.length - 1; i >= 0; i--) {\n    let n = digits.charCodeAt(i) - 48;\n    if (dbl) {\n      n *= 2;\n      if (n > 9) n -= 9;\n    }\n    sum += n;\n    dbl = !dbl;\n  }\n  return sum % 10 === 0;\n}\n```\n\n", "url": "https://wpnews.pro/news/scrubbing-api-keys-jwts-and-pii-before-pasting-logs-into-ai-chats-100-client", "canonical_source": "https://dev.to/larkandlever/scrubbing-api-keys-jwts-and-pii-before-pasting-logs-into-ai-chats-100-client-side-3c1g", "published_at": "2026-11-28 10:10:59+00:00", "updated_at": "2026-11-28 10:14:44.763155+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-safety", "large-language-models"], "entities": ["ChatGPT", "Claude", "OpenAI", "GitHub", "AWS", "Stripe", "Slack", "Google"], "also_reported_by": [], "takeaway": "Deterministic indexed placeholders like [EMAIL_1] preserve cross-line relationships for the LLM, and a Luhn checksum on digit candidates eliminates most false positives from long IDs and timestamps.", "recommendation": {"advice": "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.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/scrubbing-api-keys-jwts-and-pii-before-pasting-logs-into-ai-chats-100-client", "markdown": "https://wpnews.pro/news/scrubbing-api-keys-jwts-and-pii-before-pasting-logs-into-ai-chats-100-client.md", "text": "https://wpnews.pro/news/scrubbing-api-keys-jwts-and-pii-before-pasting-logs-into-ai-chats-100-client.txt", "jsonld": "https://wpnews.pro/news/scrubbing-api-keys-jwts-and-pii-before-pasting-logs-into-ai-chats-100-client.jsonld"}}