Skip to content

Instantly share code, notes, and snippets.

@1a1a11a
Created October 15, 2025 18:58
Show Gist options
  • Select an option

  • Save 1a1a11a/7fc337f860eac6cc6091a35ce6e9d576 to your computer and use it in GitHub Desktop.

Select an option

Save 1a1a11a/7fc337f860eac6cc6091a35ce6e9d576 to your computer and use it in GitHub Desktop.
redact_PII
from presidio_analyzer import AnalyzerEngine
from presidio_anonymizer import AnonymizerEngine
analyzer = AnalyzerEngine()
anonymizer = AnonymizerEngine()
text = "John Doe's email is [email protected] and his SSN is 123-45-6789."
results = analyzer.analyze(text=text, language='en')
anonymized_text = anonymizer.anonymize(text=text, analyzer_results=results)
print(anonymized_text.text)
# Output: <PERSON>’s email is <EMAIL_ADDRESS> and his SSN is <US_SSN>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment