webfilteringdatabase.com
Home Find Your Solution
Features
Domain Categorization API Real-Time Classification 59 Filtering Categories Offline Database (100M) ML Classification Content Classification
Industries
K-12 Schools Corporate Healthcare Government ISPs
Tools
Domain Lookup Bulk Categorization Category Explorer
Resources
Pricing API Documentation Login / Sign Up
How-To Guide

How to Redact Email Addresses

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.

8 min read
Code examples
Updated Jan 2025

Overview

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.

Before Anonymization
Contact [email protected] or [email protected] for assistance.
After Anonymization
Contact [EMAIL] or [EMAIL] for assistance.
99.5% Accuracy
Precise detection of all email formats
Domain Preservation
Option to keep or redact domain names
Format-Preserving
Maintain email structure for testing

Why Redact Email Addresses

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.

Regulatory Requirements

  • GDPR: Email addresses are personal data requiring lawful basis for processing and protection measures.
  • CCPA: Consumers have the right to know what personal information (including emails) is collected and to request deletion.
  • CAN-SPAM: Commercial email regulations require proper handling of email addresses.

Common Use Cases

  • Log Anonymization: Remove email addresses from application logs before storage or analysis.
  • Data Sharing: Share datasets with partners without exposing user contact information.
  • Testing: Create realistic test data with valid-looking but fake email addresses.
  • Analytics: Analyze user behavior patterns without identifying specific individuals.
  • Support Tickets: Archive customer support conversations without storing email addresses.

Quick Start

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"]}'

Anonymization Techniques

1. Full Redaction

Completely replaces the email with a placeholder. Maximum privacy but loses all structure.

contact: [EMAIL]

2. Domain-Preserving Redaction

Keeps the domain for context while redacting the username. Useful when domain matters for analysis.

contact: [REDACTED]@bigcorp.com

3. Format-Preserving Pseudonymization

Generates a fake but valid-looking email. Perfect for test data that needs to pass validation.

4. Partial Masking

Shows partial email for recognition while hiding identifying parts.

contact: s****@b*****.com
# 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")

Code Examples

Batch Processing Logs

# 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]

Detect Without Redacting

# 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

Best Practices

1. Combine with Name Redaction

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

2. Handle Subaddressing

The API correctly handles plus-addressing ([email protected]) used for email filtering:

newsletter: [email protected]
newsletter: [EMAIL]

3. Consider Context

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]"]}

Start Redacting Email Addresses

Protect user privacy with accurate email detection and flexible anonymization options.

Get Started Free