What is DataFog?
DataFog is a Python library for detecting and redacting personally identifiable information (PII). It sits in the Guardrails & Security category of the Evaluation & Production Ops tools and is open-source, written in Python. To get started: install DataFog.
Overview
DataFog is a Python library for detecting and redacting personally identifiable information (PII). The core install ships a fast regex engine that finds structured entities like emails, phone numbers, SSNs, credit cards, and IP addresses, and you can add NLP, OCR, or Spark support as optional extras only when you need them.
It is aimed at teams building LLM applications who want to scrub user prompts and model output before that data leaves their control. The library exposes simple helpers such as `sanitize`, `scan_prompt`, and `filter_output`, plus a reusable guardrail decorator you can wrap around any function that calls a model.
As a PII and security tool, DataFog sits in front of your LLM calls. The default regex engine is always available and needs no extra dependencies, while the `spacy`, `gliner`, and `smart` engines trade more setup for stronger coverage of unstructured names and organizations.
What it does
- Fast structured PII detection via regex for emails, phones, SSNs, credit cards, IP addresses, dates, and ZIP codes
- Optional NER engines (spaCy and GLiNER) for unstructured entities like person and organization names
- A `smart` engine that cascades regex with optional NER and degrades gracefully when those deps are missing
- LLM-focused helpers: `scan_prompt`, `filter_output`, `sanitize`, and a reusable `create_guardrail` decorator
- Opt-in German structured PII via `locales=["de"]` for VAT IDs, IBANs, tax IDs, postal codes, and more
- A CLI for scanning, redacting, pseudonymizing, and hashing text, plus optional OCR and Spark surfaces
Getting started
Install the core package and redact PII from text in a few lines. The default regex engine needs no extra dependencies.
Install DataFog
Install the core package with the regex engine. Optional extras add spaCy, GLiNER, OCR, or Spark support.
pip install datafogRedact PII in one line
Use `sanitize` with the regex engine to replace detected PII with typed placeholders.
import datafog
text = "Contact john@example.com or call (555) 123-4567"
clean = datafog.sanitize(text, engine="regex")
print(clean)
# Contact [EMAIL_1] or call [PHONE_1]Guard an LLM call
Scan prompts before sending them and redact model output before returning it, or wrap a function with a reusable guardrail.
import datafog
# Scan a prompt before sending it to an LLM
scan_result = datafog.scan_prompt("My SSN is 123-45-6789", engine="regex")
if scan_result.entities:
print(f"Detected {len(scan_result.entities)} PII entities")
# Redact model output before returning it
safe = datafog.filter_output("Email me at jane.doe@example.com", engine="regex")
print(safe.redacted_text)
# Email me at [EMAIL_1]Try the CLI
Scan, redact, pseudonymize, or hash text straight from the terminal.
datafog redact-text "john@example.com"Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Strip emails, phone numbers, and SSNs out of user prompts before sending them to an LLM API
- Redact model output so PII never leaks back to the end user
- Wrap LLM-calling functions in a reusable guardrail decorator to enforce redaction in one place
- Scan or hash PII in batch text with the CLI, or scale detection over large datasets with the Spark extra
How DataFog compares
DataFog alongside other open-source guardrails & security tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| SkillSpector | ★ 28.3k | Security scanner for AI agent skills that checks a skill for prompt injection, data exfiltration, privilege escalation and supply-chain risks before you install it. |
| Presidio | ★ 12.1k | An open-source framework for detecting, redacting, masking, and anonymizing personal data (PII) across text, images, and structured data using NER models, regex, and rule-based recognizers. |
| Failproof AI | ★ 10.5k | A hook-based CLI and Rust daemon that listens to every event from 12 agent harnesses such as Claude Code, Codex and Cursor, and blocks, warns or steers the agent with one policy API, with optional cloud tracing and failure audits. |
| Guardrails AI | ★ 7.7k | A Python framework that wraps LLM calls with composable input/output validators (from the Guardrails Hub) to check structure, type, and safety risks before responses reach users. |
| NeMo Guardrails | ★ 7.6k | NVIDIA's toolkit for adding programmable rails to LLM chat apps, using the Colang language to control dialog flow and block jailbreaks, prompt injection, and off-topic answers. |
| BLA (Blind LLM Agents) | ★ 7.3k | An open-source CLI and MCP server that hardens the apps, WASM modules, databases and model files you ship so AI reverse-engineering agents such as REA hit resource budgets and follow decoys, without changing runtime behaviour. |
| dcg (Destructive Command Guard) | ★ 6.4k | A Rust pre-tool hook for coding agents that inspects each shell or git command before it runs and blocks the destructive ones, with an explanation and a safer alternative. |
| DataFog | ★ 80 | Detect and redact PII from text before it reaches your LLM |

