Presidio Analyzer

The PII detection engine behind Presidio, combining NER, regex, and checksum recognizers

Library
PyPI
v2.2.364
10,539stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
89/100Excellent
Development Activity96
Maintenance84
Community76
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture87
Code Quality88
Innovation82
Learning Curve62

Presidio Analyzer is the identification engine at the core of Presidio, an open-source framework for detecting, redacting, and anonymizing personally identifiable information (PII) in text. It runs a pluggable AnalyzerEngine over input text using an extensible registry of recognizers — spaCy/transformer-based NER, regular expressions, checksum validators, and context-aware confidence boosting — to flag entities like credit card numbers, national IDs, phone numbers, and dozens of country-specific identifiers, and hands the results off to sibling packages like Presidio Anonymizer for redaction or masking.

What You Get

  • An AnalyzerEngine that scans text and returns RecognizerResult objects with entity type, span, and confidence score
  • Dozens of predefined recognizers for country-specific PII (SSNs, passports, tax IDs, bank accounts, driver’s licenses) across the US, EU, UK, and more
  • Pluggable NLP engine support for spaCy, Hugging Face transformers, Stanza, and GLiNER-based NER models
  • Context-aware confidence enhancement that boosts recognition scores based on nearby keywords
  • A BatchAnalyzerEngine for processing lists/dicts of text at scale, plus YAML-driven configuration for custom recognizer pipelines

Common Use Cases

  • Scanning documents, chat logs, or support tickets for PII before storage or export
  • Building LLM input/output guardrails that flag or redact sensitive data in prompts and completions
  • Compliance tooling that needs to locate GDPR/CCPA-regulated personal data across text corpora
  • Feeding detected entities into Presidio Anonymizer or Presidio Image Redactor for downstream de-identification

Under The Hood

Architecture: presidio_analyzer/analyzer_engine.py orchestrates a RecognizerRegistry (recognizer_registry/) that holds every active EntityRecognizer; each recognizer subclasses either PatternRecognizer (regex + validation) or a model-backed recognizer wired through nlp_engine/ (spaCy/transformers/Stanza/GLiNER adapters), and results flow through context_aware_enhancers/ to adjust confidence before being returned as RecognizerResult objects. Tech Stack: Python 3.10+, built on spaCy for core NLP with optional transformer/Stanza/GLiNER backends, packaged with Poetry, and configurable via YAML through analyzer_engine_provider.py. Code Quality: an exceptionally large tests/ suite (100+ files, one per country-specific recognizer) validates detection accuracy per entity type, backed by CI coverage tracking per sub-package and py.typed for type-checker support. API Design: the recognizer-registry pattern makes adding a custom entity type a matter of subclassing PatternRecognizer or EntityRecognizer rather than modifying core code, and the same AnalyzerEngine.analyze() call works uniformly whether the underlying detection is regex-based or a full NER model.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search