Skip to main content
Creates and configures an anonymizer instance for PII detection and replacement.

Signature

Parameters

config (optional)

mode
string
default:"'pseudonymize'"
Anonymization mode:
  • 'pseudonymize' — Reversible. Returns an encrypted piiMap for later rehydration.
  • 'anonymize' — Irreversible. No piiMap is returned; PII is permanently removed.
ner
NERConfig
NER model configuration
semantic
SemanticConfig
Semantic enrichment configuration
keyProvider
KeyProvider
Encryption key provider. If not provided, generates a random key.
piiStorageProvider
PIIStorageProvider
Storage provider for session-based PII map persistence
defaultPolicy
AnonymizationPolicy
Default anonymization policy
secrets
SecretsConfig
Secrets/credentials detection configuration
tagFormat
TagFormat
Tag format for PII placeholder tags. Controls the delimiters and keyword.
onValidationWarning
(warnings: Array<{ code: string; message: string }>) => void
Callback for validation warnings. When not provided, warnings are silently ignored — check stats.leakScanPassed in the result instead.
registry
RecognizerRegistry
Custom recognizer registry (uses default if not provided)

Returns

An Anonymizer instance with these methods:

Examples

Basic (Regex Only)

With NER

With Semantic Enrichment

With Storage

Irreversible Anonymization

With Inference Server

With Custom Tag Format

With Custom Thresholds

With Custom Policy

Excluding Countries and Regions