DevTools Logo

LLM Guardrails & PII Redactor

LLM Guardrails & PII Redactor

Build and test deterministic PII redaction rules entirely in your browser

Rule editor

  • Email
  • Phone (TR / international)
  • T.C. identity number
  • Credit card (Luhn)
  • IBAN (Turkey)
  • IPv4 address
  • US SSN

Test text

Rule set JSON

Built-in email, phone, T.C. identity, Luhn credit card, Turkish IBAN, IPv4, and SSN detectors plus custom regular expressions. All processing is client-side.

Examples

TCKN plus Luhn filtering

Input
scanGuardrails("IDs: 10000000146, 10000000147", defaultGuardrailRules())
Output
{ findings: [{ ruleId: "tckn", match: "10000000146" }] }

The checksum-valid TCKN is flagged while the failing neighbor is skipped.

Custom API-key rule

Input
scanGuardrails("Key sk-Ab12Cd34", [...defaults, { id: "api-key", pattern: "sk-[A-Za-z0-9]{8}", strategy: "mask" }])
Output
{ redactedText: "Key ***********" }

A custom regex appends cleanly and masks with same-length asterisks.

About this tool

LLM Guardrails Builder redacts sensitive text with scanGuardrails(text, rules): defaultGuardrailRules ships email, TR/international phone, T.C. identity number (checksum-validated), credit card (Luhn-validated), Turkey IBAN, IPv4, and US SSN patterns, each with mask/hash/remove strategies. Findings carry ruleId, ruleName, start/end offsets, match, and strategy, and redactedText applies non-overlapping replacements in order.

Validation is strict where it matters: TCKN candidates must pass the 11-digit checksum (leading zero rejected) and card candidates must pass Luhn, so card-like digit runs that fail the check are left untouched. Masking replaces each character with *, hashing emits a stable [HASH_xxxxxxxx] FNV-1a digest, and remove deletes the match.

Rule sets round-trip as JSON via exportGuardrailRules/importGuardrailRules (versioned { version: 1, rules }), custom rules add any { id, name, pattern, flags, strategy } regex, and invalid patterns are skipped instead of throwing while malformed rule-set JSON throws a clear error.

How to use this tool

  1. Load the defaults

    Call defaultGuardrailRules for the seven built-ins, then append custom { id, pattern, strategy } entries as needed.

  2. Scan the text

    Run scanGuardrails and read findings for offsets plus redactedText for the safe-to-log version.

  3. Choose a strategy

    Use mask for same-length redaction, hash for joinable pseudonyms, or remove for full deletion.

  4. Persist the rule set

    Export to JSON for review and re-import on load; invalid files throw an explicit error.

Use cases

Scrubbing prompts before logging

Redact emails, phones, TCKN, cards, IBANs, and IPs from LLM inputs before they hit disks or vendors.

Enforcing TR data handling

Catch T.C. identity numbers and Turkey IBANs with checksum-aware rules tuned for Turkish formats.

Sharing versioned redaction policy

Export the rule set as JSON so reviewers audit patterns and strategies in pull requests.

Common mistakes

Mistake:Assuming every 11-digit number is a TCKN.

Fix:Only checksum-passing values flag — leading-zero and failing numbers are intentionally ignored.

Mistake:Expecting card-like digits to always redact.

Fix:Card candidates must pass Luhn; 4111 1111 1111 1112 stays visible because the check digit fails.

Mistake:Using overlapping custom patterns without ordering.

Fix:Overlaps resolve by start offset, so keep the narrower rule first or widen one pattern to avoid shadowing.

Frequently asked questions

What does this tool do?

It redacts sensitive text with scanGuardrails: email, phone, checksum-validated TCKN, Luhn-validated cards, Turkey IBAN, IPv4, and SSN built-ins with mask/hash/remove strategies, plus custom regex rules and JSON export/import.

Why was one TCKN or card number skipped?

Only checksum-passing values flag — 10000000146 redacts but 10000000147 does not, and 4111 1111 1111 1112 stays visible because it fails Luhn.

Is my text uploaded or stored?

No. Pattern matching, checksum checks, and redaction run entirely in your browser.

How does masking look, and how do custom rules work?

Masking replaces each character with * at the same length. Add any { id, name, pattern, strategy } regex (e.g. sk-[A-Za-z0-9]{8}) and it scans alongside the built-ins.

References & standards