Presidio
MIT-licensed SDK for context-aware PII detection and anonymization in text, images (including DICOM) and structured data. Created by Microsoft, now community-governed under Data Privacy Stack.
What it is
Presidio is an open-source SDK for finding and removing personal data. Its analyzer scans text for entities such as names, email addresses, phone numbers, credit card numbers, IBANs and national IDs. It combines named-entity recognition, regular expressions, rule logic, checksums and surrounding context words. The anonymizer then redacts, replaces, masks, hashes or encrypts each finding. Separate modules handle images (including DICOM medical scans) and structured or tabular data.
Microsoft created Presidio. It is now an independent, community-governed project under the Data Privacy Stack organisation on GitHub, and Microsoft supported the transition. Data engineers, privacy teams and AI developers use it to clean tickets, logs and transcripts before storing or sharing them. It is especially common as a filter that strips PII from prompts and responses around an LLM.
Key features
- Built-in recognizers for dozens of PII types across many countries, with context words that raise or lower confidence scores
- Pluggable NLP engines: spaCy (default), Hugging Face Transformers and Stanza, plus GLiNER and LLM-based recognizers through optional extras
- Custom recognizers from regex patterns, deny-lists or your own Python code, for in-house identifiers and other languages
- Anonymization operators: replace, redact, mask, hash, encrypt (reversible with a key) and custom functions
- Image redactor that uses OCR to blank out PII in screenshots, scans and DICOM files
- Structured-data module for DataFrames and JSON, plus samples for PySpark and batch jobs
- REST services packaged as containers for language-agnostic or Kubernetes deployments
Install
Python 3.11 to 3.14, on any OS:
pip install presidio-analyzer presidio-anonymizer
python -m spacy download en_core_web_lg
Transformers-based detection instead of spaCy NER:
pip install "presidio_analyzer[transformers]" presidio-anonymizer
python -m spacy download en_core_web_sm
Image redaction (Tesseract OCR must also be installed on the system):
pip install presidio_image_redactor
Docker images now live on GitHub Container Registry. Each service listens on port 3000 inside the container:
docker run -d -p 5002:3000 ghcr.io/data-privacy-stack/presidio-analyzer:latest
docker run -d -p 5001:3000 ghcr.io/data-privacy-stack/presidio-anonymizer:latest
Getting started
A minimal detect-then-anonymize run in Python:
from presidio_analyzer import AnalyzerEngine
from presidio_anonymizer import AnonymizerEngine
text = "Call Jane Doe on 212-555-5555 or mail jane@example.com"
results = AnalyzerEngine().analyze(text=text, language="en")
print(results)
print(AnonymizerEngine().anonymize(text=text, analyzer_results=results).text)
The first print lists each finding with its entity type, start and end offsets, and a confidence score. The second prints the text with placeholders such as <PERSON>, <PHONE_NUMBER> and <EMAIL_ADDRESS>. Use the scores to set a threshold, and test on your own sample data before trusting the defaults.
Good to know
- Licence: MIT, free, with no paid tier. Support comes from the community through GitHub Discussions and Discord.
- Automated detection is never complete. Expect missed entities and false positives, especially in non-English text, unusual formats or very short strings. Keep a human review step for high-risk data.
- The large spaCy model is several hundred MB and loads into RAM at start-up. Transformer models are heavier and benefit from a GPU (
pip install "spacy[cuda12x]"on NVIDIA/Linux). - The old Microsoft repo and docs URLs redirect to the new home. The legacy
mcr.microsoft.com/presidio-*images are no longer updated, so switch to the GHCR images and pin a release tag in production. - No special privileges are needed. Run it as a normal user or service account, and never log the raw input text you are trying to protect.
Alternatives
- Google Cloud Sensitive Data Protection (Cloud DLP): a managed API with many detectors, if you are fine sending data to Google Cloud.
- Amazon Comprehend PII detection: a managed option for teams already working in AWS.
- spaCy or GLiNER on their own: for teams that only need NER and want to build their own redaction logic.
