A small offline command-line tool that redacts common personally identifiable information (PII) from text.
This is a practical baseline for safely sharing:
- support tickets
- user reports
- logs / incident writeups
- documentation snippets
No API keys. No external services.
- Emails →
[REDACTED_EMAIL] - Phone numbers →
[REDACTED_PHONE](conservative patterns) - IPv4 addresses →
[REDACTED_IP] - IBANs →
[REDACTED_IBAN] - URLs (optional) →
[REDACTED_URL]
Use the Python Launcher:
py redact.py --in examples/input.txt --print --urlsIf python3 is available:
python3 redact.py --in examples/input.txt --print --urlspy redact.py --in examples/input.txt --print --urlsWrite output to a file:
py redact.py --in examples/input.txt --out examples/output.txt --urlsShow stats as JSON (printed to stderr):
py redact.py --in examples/input.txt --out examples/output.txt --urls --json-statsPowerShell example:
Get-Content -Raw examples/input.txt | py redact.py --stdin --print --urlspy -m pip install -r requirements-dev.txtpy -m pytestGitHub Actions runs the same tests on every push / PR.
This is a regex-based baseline:
- It can miss edge cases (false negatives).
- It can sometimes redact too much (false positives).
For production hardening you could add:
- stricter country-specific phone patterns
- IBAN checksum validation
- Named Entity Recognition (NER) for names/locations
- optional LLM-assisted redaction (still keeping secrets out of the repo)
MIT