LLM Prompt PII Sanitizer & Restorer

Mask API keys, emails, and sensitive data before sending to AI, then restore responses.

Developer & Code
100% Client-Side · Private & Secure
LLM Prompt PII Sanitizer & Restorer

Mask API keys, emails, and sensitive data before sending to AI, then restore responses.

Concept & Knowledge Hub

LLM Prompt Sanitization: Preventing PII Leaks

Personally Identifiable Information (PII) includes any data that could uniquely identify a specific individual, such as social security numbers, email addresses, phone numbers, or proprietary API keys.

Pasting raw customer data into third party LLMs (like ChatGPT or Claude) is a massive GDPR compliance violation. This sanitizer utilizes complex RegEx patterns to detect and mask sensitive entities entirely client side, before the prompt ever touches the network.

Core Architecture & Mathematical Formula

Raw Text + RegEx Detectors ➔ MASKED_ENTITY ➔ API Call ➔ Re-injection

The system replaces real emails with placeholders like `[EMAIL_1]`, sends the anonymized text to the AI, and upon receiving the response, automatically swaps the real emails back into the text.

Best Practices & Essential Guidelines

  • Never Trust AI Providers with Secrets: Even if an AI provider claims they do not train on API inputs, server side logs can be hacked or subpoenaed. If the data never leaves your browser, it cannot be leaked.
  • Sanitize Internal IDs: Beyond just names and emails, ensure you sanitize internal database UUIDs or sequential customer IDs, as these can leak information about your scale or user volume to competitors.
  • Review Masked Output Manually: RegEx detection is not perfect. Always visually inspect the sanitized output to ensure a highly non standard email address or formatted phone number did not slip past the filters.

Frequently Asked Questions (FAQ)

Does masking data confuse the LLM?
Generally, no. Modern LLMs understand contextual placeholders perfectly. If you say 'Send an email to [EMAIL_1] thanking them', the LLM will generate the correct template without needing to know the actual address.
What is GDPR?
The General Data Protection Regulation (GDPR) is a strict European Union law that imposes massive fines on companies that recklessly transmit or store EU citizens' personal data without explicit consent.
Can the sanitizer catch passwords?
It can catch highly structured secrets (like AWS keys or JWTs) using standard algorithms, but it cannot reliably detect a generic string like 'MyPassword123!' scattered randomly in text. Always manually redact passwords.