Skip to main content

chad-pii

Find and redact personal data in text with one line of Python.

pip install chad-pii
from chad_pii import redact

redact("Hi, I'm Sarah Johnson. Email sarah.j@example.com or call 6626341142.")
# "Hi, I'm [PERSON]. Email [EMAIL] or call [PHONE]."

It finds names, emails, phone numbers, Social Security numbers, card numbers, IP addresses, passports, driver's licenses, API keys and IBANs, in English and Spanish. A fine-tuned DistilBERT model (ChadTollison/pii-distilbert-v2) does the finding, and rules double-check it: card numbers must pass Luhn, IBANs their bank checksum, SSNs the SSA format. The rules also catch 10-digit US phone numbers with a real area code, valid IBANs and well-known API key formats even if the model misses them.

The model (about 260 MB) downloads on first use and is cached, so after that it works offline. Nothing is sent anywhere.

Try it in your browser first: chadtollison.github.io/redact.html

Ways to redact

text = "Call Sarah Johnson at 662-634-1142."

redact(text)                # Call [PERSON] at [PHONE].
redact(text, mode="mask")   # Call █████████████ at ████████████.
redact(text, mode="fake")   # Call Avery Brooks at (202) 555-0117.

Fake values are harmless on purpose: phones use the 555-01xx range reserved for fiction, cards are public test numbers, IPs come from the documentation range, and SSNs start with 9, which is never issued.

Reversible tokens

from chad_pii import tokenize, restore

safe, key = tokenize(text)
# safe == "Call <PERSON_1> at <PHONE_1>."
# key  == {"<PERSON_1>": "Sarah Johnson", "<PHONE_1>": "662-634-1142"}

restore(safe, key)          # back to the original

Handy for sending text to another service (an LLM, a ticketing tool) and putting the real values back in its reply.

Just find

from chad_pii import find

for e in find(text):
    print(e.type, e.text, e.start, e.end, round(e.score, 2), e.rule)

min_score (default 0.5) sets how sure the model must be. Items caught or confirmed by a rule are always returned.

Command line

chad-pii "Call Sarah at 662-634-1142"
cat notes.txt | chad-pii --mode mask > notes-redacted.txt
chad-pii --find "My SSN is 123-45-6789"

Limits

This is a research model. It can miss things or flag things by mistake, so please don't rely on it alone for compliance work.

MIT licensed. Made by Michael Chad Tollison.

Metadata

Release files for chad-pii 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chad-pii 0.1.0
File Size Uploaded Provenance Actions
chad_pii-0.1.0.tar.gz 9.3 kB With provenance Details for chad_pii-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for chad-pii 0.1.0
File Interpreter ABI Platform Actions
chad_pii-0.1.0-py3-none-any.whl Python 3 none any Details for chad_pii-0.1.0-py3-none-any.whl

Total release size: 19.1 kB

Release files / chad_pii-0.1.0.tar.gz

Download URL chad_pii-0.1.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fb159429ac9079e37f767acd2150c228bf7304ec5d1090e6a003f6cc089d1397
BLAKE2b-256 checksum
How to use checksums
aa4f1ace2b51e11a9375ab4aa5dc7c3cae6de1615a29582eb0c8bc8382df2b7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / chad_pii-0.1.0-py3-none-any.whl

Download URL chad_pii-0.1.0-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
70f014ee6c7273c085fcab0373334b959ac9727acd1d49261d81e519e122c01b
BLAKE2b-256 checksum
How to use checksums
af2523c4772acdc098392e7c1f6be1a7721265151523cecdb20f5be242f8545d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for chad-pii 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for chad_pii-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page