# scrubadub

> Remove personally identifiable information from free text in Python

- Category: Evaluation & Production Ops / Guardrails & Security
- Language: Python
- Repository: https://github.com/LeapBeyond/scrubadub
- Website: https://scrubadub.readthedocs.io/
- Canonical page: https://ai-tldr.dev/tools/scrubadub/

## In short

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.

1. Install scrubadub

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

```bash
pip install scrubadub
```

2. Clean a piece of text

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

```python
>>> 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}}'
```

3. Add optional detectors

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

```bash
pip install scrubadub_address scrubadub_spacy scrubadub_stanford
```

## 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
