█

AI/TLDR

Buy me a coffee
Buy me a coffee

scrubadub

Remove personally identifiable information from free text in Python

Guardrails & SecurityOpen source
Language
Python
$pip install scrubadub
IN SHORT

What is scrubadub?

scrubadub is a Python library that detects and removes personally identifiable information (PII) from free text. It sits in the Guardrails & Security category of the Evaluation & Production Ops tools and is open-source, written in Python. To get started: install scrubadub.

Overview

scrubadub is a Python library that detects and removes personally identifiable information (PII) from free text. It replaces things like email addresses, phone numbers, names, and credit card numbers with anonymous placeholder tags such as {{EMAIL}} or {{PHONE}}, so you can keep working with the text without exposing the people it mentions.

It is aimed at developers and data teams who need to anonymize logs, support tickets, survey responses, or other unstructured text before storing, sharing, or analyzing it. The library works on plain text and does not require any metadata about the people involved, though it can use extra context when you have it.

Within the PII and security space, scrubadub sits at the pre-processing stage. Its behavior is built from individual Detectors and PostProcessors, so you can turn detectors on or off and add optional plugins (like spaCy or Stanford NER for names, plus an address detector) to match the languages and regions you care about.

What it does

  • Detects and removes many PII types out of the box: names, email addresses, phone numbers, URLs, credit card numbers, dates of birth, and more
  • Replaces detected items with clear placeholder tags such as {{EMAIL}} and {{PHONE}}
  • Handles region-specific identifiers, including US/GB/CA postal addresses, US SSNs and GB national insurance numbers, GB tax and driving licence numbers
  • Configurable through individual Detectors and PostProcessors, with localisation support for different languages and regions
  • Optional plugin packages (scrubadub_address, scrubadub_spacy, scrubadub_stanford) add NER-based name and address detection
  • Pure Python, installable from PyPI, requiring Python 3.6 or newer

Getting started

Getting started is as simple as installing from PyPI and calling scrubadub.clean() on your text.

Install scrubadub

Install the core library from PyPI. It requires Python 3.6 or newer.

bashbash
pip install scrubadub

Clean a piece of text

Import the package and pass your text to scrubadub.clean(). Detected personal information is replaced with placeholder tags.

pythonpython
>>> import scrubadub
>>> text = "My cat can be contacted on example@example.com, or 1800 555-5555"
>>> scrubadub.clean(text)
'My cat can be contacted on {{EMAIL}}, or {{PHONE}}'

Add optional detectors

For NER-based name and address detection, install the optional plugin packages and follow their documentation. These require additional dependencies.

bashbash
pip install scrubadub_address scrubadub_spacy scrubadub_stanford

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Anonymizing support tickets, chat logs, or emails before storing or sharing them
  • Stripping PII from text datasets prior to analysis or model training
  • Redacting customer free-text fields (surveys, feedback forms) to meet privacy requirements
  • Pre-processing documents to remove names, phone numbers, and IDs before publishing or exporting

How scrubadub compares

scrubadub alongside other open-source guardrails & security tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
SkillSpector★ 28.3kSecurity 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.1kAn 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.5kA 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.7kA 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.6kNVIDIA'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.3kAn 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.4kA 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.
scrubadub★ 433Remove personally identifiable information from free text in Python