PII Sanitization
Compare all sanitization presets side-by-side. See how different compliance requirements affect data masking.
NNode.jsServer
Sample Data (Unsanitized)
This is the raw data that will be sanitized with each preset
Result
{
"user": {
"name": "John Doe",
"email": "john.doe@example.com",
"password": "super_secret_123",
"ssn": "123-45-6789",
"phone": "+1 (555) 123-4567"
},
"payment": {
"cardNumber": "4111-1111-1111-1111",
"cvv": "123",
"expiryDate": "12/25",
"billingAddress": "123 Main St, New York, NY 10001"
},
"medical": {
"patientId": "PAT-2024-001",
"diagnosis": "Common cold",
"medications": [
"Acetaminophen",
"Vitamin C"
],
"insuranceId": "INS-987654321"
},
"api": {
"apiKey": "sk_live_abc123xyz789",
"secretToken": "ghp_xxxxxxxxxxxxxxxxxxxx",
"bearerToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.test"
}
}Preset Comparison
none
No sanitization - shows raw data (not recommended for production)
{
"user": {
"name": "John Doe",
"email": "john.doe@example.com",
"password": "super_secret_123",
"ssn": "123-45-6789",
"phone": "+1 (555) 123-4567"
},
"payment": {
"cardNumber": "4111-1111-1111-1111",
"cvv": "123",
"expiryDate": "12/25",
"billingAddress": "123 Main St, New York, NY 10001"
},
"medical": {
"patientId": "PAT-2024-001",
"diagnosis": "Common cold",
"medications": [
"Acetaminophen",
"Vitamin C"
],
"insuranceId": "INS-987654321"
},
"api": {
"apiKey": "sk_live_abc123xyz789",
"secretToken": "ghp_xxxxxxxxxxxxxxxxxxxx",
"bearerToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.test"
}
}minimal
Basic sanitization - passwords and secrets only
{
"user": {
"name": "John Doe",
"email": "john.doe@example.com",
"password": "[REDACTED]",
"ssn": "123-45-6789",
"phone": "+1 (555) 123-4567"
},
"payment": {
"cardNumber": "4111-1111-1111-1111",
"cvv": "123",
"expiryDate": "12/25",
"billingAddress": "123 Main St, New York, NY 10001"
},
"medical": {
"patientId": "PAT-2024-001",
"diagnosis": "Common cold",
"medications": [
"Acetaminophen",
"Vitamin C"
],
"insuranceId": "INS-987654321"
},
"api": {
"apiKey": "[REDACTED]",
"secretToken": "ghp_xxxxxxxxxxxxxxxxxxxx",
"bearerToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.test"
}
}default
Standard sanitization - common PII fields and patterns
{
"user": {
"name": "John Doe",
"email": "jo***@example.com",
"password": "[REDACTED]",
"ssn": "[REDACTED]",
"phone": "+1 (555) 123-4567"
},
"payment": {
"cardNumber": "****1111",
"cvv": "[REDACTED]",
"expiryDate": "12/25",
"billingAddress": "123 Main St, New York, NY 10001"
},
"medical": {
"patientId": "PAT-2024-001",
"diagnosis": "Common cold",
"medications": [
"Acetaminophen",
"Vitamin C"
],
"insuranceId": "INS-987654321"
},
"api": {
"apiKey": "[REDACTED]",
"secretToken": "ghp_xxxxxxxxxxxxxxxxxxxx",
"bearerToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.test"
}
}gdpr
GDPR compliant - EU personal data protection requirements
{
"user": {
"name": "[REDACTED]",
"email": "[REDACTED]",
"password": "[REDACTED]",
"ssn": "[REDACTED]",
"phone": "[REDACTED]"
},
"payment": {
"cardNumber": "****1111",
"cvv": "[REDACTED]",
"expiryDate": "12/25",
"billingAddress": "123 Main St, New York, NY 10001"
},
"medical": {
"patientId": "PAT-2024-001",
"diagnosis": "Common cold",
"medications": [
"Acetaminophen",
"Vitamin C"
],
"insuranceId": "INS-987654321"
},
"api": {
"apiKey": "[REDACTED]",
"secretToken": "ghp_xxxxxxxxxxxxxxxxxxxx",
"bearerToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.test"
}
}hipaa
HIPAA compliant - Healthcare data protection (US)
{
"user": {
"name": "[REDACTED]",
"email": "[REDACTED]",
"password": "[REDACTED]",
"ssn": "[REDACTED]",
"phone": "[REDACTED]"
},
"payment": {
"cardNumber": "****1111",
"cvv": "[REDACTED]",
"expiryDate": "12/25",
"billingAddress": "123 Main St, New York, NY 10001"
},
"medical": {
"patientId": "[REDACTED]",
"diagnosis": "[REDACTED]",
"medications": [
"Acetaminophen",
"Vitamin C"
],
"insuranceId": "INS-[SSN_REDACTED]"
},
"api": {
"apiKey": "[REDACTED]",
"secretToken": "ghp_xxxxxxxxxxxxxxxxxxxx",
"bearerToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.test"
}
}pci-dss
PCI-DSS compliant - Payment card industry standards
{
"user": {
"name": "John Doe",
"email": "john.doe@example.com",
"password": "[REDACTED]",
"ssn": "[REDACTED]",
"phone": "+1 (555) 123-4567"
},
"payment": {
"cardNumber": "[REDACTED]",
"cvv": "[REDACTED]",
"expiryDate": "12/25",
"billingAddress": "123 Main St, New York, NY 10001"
},
"medical": {
"patientId": "PAT-2024-001",
"diagnosis": "Common cold",
"medications": [
"Acetaminophen",
"Vitamin C"
],
"insuranceId": "INS-987654321"
},
"api": {
"apiKey": "[REDACTED]",
"secretToken": "ghp_xxxxxxxxxxxxxxxxxxxx",
"bearerToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.test"
}
}Code Example
How to use sanitization presets in your code
typescript
import { createLogger, sanitize } from 'vestig'
// Using preset in logger config
const log = createLogger({
sanitize: 'gdpr', // or 'hipaa', 'pci-dss', 'default', 'minimal'
})
// All logs automatically sanitized
log.info('User login', {
email: 'john@example.com', // → [EMAIL REDACTED]
password: 'secret123', // → [REDACTED]
creditCard: '4111-1111-1111', // → [CARD REDACTED]
})
// Direct sanitization
const cleanData = sanitize(userData, { preset: 'hipaa' })Sanitized Field Types
Types of data automatically detected and sanitized
Result
password
email
creditCard
ssn
phone
apiKey
token
secret
address
— Key Features
- ›6 Built-in Presets — From minimal to compliance-ready (GDPR, HIPAA, PCI-DSS)
- ›Automatic Detection — Recognizes emails, credit cards, SSNs, tokens, and more
- ›Deep Object Sanitization — Recursively sanitizes nested objects and arrays
- ›Custom Patterns — Add your own field matchers and regex patterns
- ›Zero Dependencies — Lightweight and fast, no external libraries