Learn how to automatically detect and redact email addresses from text, documents, and datasets. Protect user privacy with format-preserving anonymization that maintains data utility.
Email addresses are critical personally identifiable information (PII) that uniquely identify individuals and serve as primary contact methods. They often contain personal names, employer information, and other identifying details that make proper redaction essential for privacy compliance.
Anonymization API detects email addresses with 99.5% accuracy using pattern matching combined with contextual analysis. Our system handles standard formats, subaddressing ([email protected]), international domains, and edge cases like emails embedded in URLs.
Email addresses are among the most sensitive PII because they serve multiple purposes: identification, communication, and often authentication. Exposing email addresses can lead to spam, restricted content attacks, identity theft, and regulatory violations.
Redact email addresses with a single API call:
from anonymization import Client client = Client(api_key="your_api_key") result = client.anonymize( text="Email me at [email protected]", entity_types=["EMAIL"] ) print(result.anonymized_text) # Output: Email me at [EMAIL]
const client = new AnonymizationClient('your_api_key'); const result = await client.anonymize({ text: "Email me at [email protected]", entityTypes: ["EMAIL"] }); console.log(result.anonymizedText); // Output: Email me at [EMAIL]
curl -X POST https://api.anonymizationapi.com/v2/anonymize \ -H "Authorization: Bearer your_api_key" \ -H "Content-Type: application/json" \ -d '{"text": "Email me at [email protected]", "entity_types": ["EMAIL"]}'
Completely replaces the email with a placeholder. Maximum privacy but loses all structure.
Keeps the domain for context while redacting the username. Useful when domain matters for analysis.
Generates a fake but valid-looking email. Perfect for test data that needs to pass validation.
Shows partial email for recognition while hiding identifying parts.
# Full redaction (default) result = client.anonymize(text, mode="redact") # Preserve domain result = client.anonymize(text, mode="redact", options={"email_preserve_domain": True}) # Format-preserving fake email result = client.anonymize(text, mode="pseudonymize") # Partial masking result = client.anonymize(text, mode="mask")
# Anonymize emails in log entries log_entries = [ "User [email protected] logged in", "Password reset for [email protected]", "New signup: [email protected]" ] results = client.batch_anonymize( items=[{"text": log} for log in log_entries], entity_types=["EMAIL"] ) for r in results: print(r.anonymized_text) # User [EMAIL] logged in # Password reset for [EMAIL] # New signup: [EMAIL]
# Find emails without modifying text result = client.detect( text="Contact [email protected] or [email protected]", entity_types=["EMAIL"] ) for entity in result.entities: print(f"Found: {entity.text} at position {entity.start}-{entity.end}") # Found: [email protected] at position 8-28 # Found: [email protected] at position 32-50
Email addresses often contain names. Redact both for complete privacy:
result = client.anonymize( text="John Smith ([email protected]) submitted the form", entity_types=["PERSON", "EMAIL"] ) # Output: [PERSON] ([EMAIL]) submitted the form
The API correctly handles plus-addressing ([email protected]) used for email filtering:
Email addresses in different contexts may need different handling. Support emails might be kept while customer emails are redacted.
Pro Tip: Use an allow-list for company or support emails that should remain visible: options={"allow_list": ["[email protected]"]}
Protect user privacy with accurate email detection and flexible anonymization options.
Get Started Free