🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@cdssnc/sanitize-pii

Package Overview
Dependencies
Maintainers
9
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cdssnc/sanitize-pii

TypeScript module for removing personally identifiable information (PII) from text

latest
Source
npmnpm
Version
2.1.0
Version published
Maintainers
9
Created
Source

Sanitize PII

TypeScript module for removing personally identifiable information (PII) from text. The PII this module removes by default can be seen in src/patterns.ts.

Installation

npm install @cdssnc/sanitize-pii

Quick start

import { sanitizePii, PiiSanitizer } from '@cdssnc/sanitize-pii';

// Simple usage with default patterns
const text = "Contact me at (555) 123-4567 with Account ID 1234";
const sanitized = sanitizePii(text);
console.log(sanitized);
// Output: "Contact me at [Redacted: phone_number] with Account ID 1234"

// Sanitizer with custom replacement template and pattern
const sanitizer = new PiiSanitizer({
  replacementTemplate: '***{name}***',
  patterns: [
    {
      name: 'account_id',
      regex: /\bAccount\sID\s\d{4}\b/g,
    }
  ]
});

const result = sanitizer.sanitize(text);
console.log(result);
// Output: "Contact me at ***phone_number*** with ***account_id***"

You can also use the module directly in a browser with the following CDN:

<script src="https://cdn.jsdelivr.net/npm/@cdssnc/sanitize-pii@1.1.1/dist/umd/sanitize-pii.min.js"></script>
<script>
  const textareas = document.querySelectorAll('textarea');
  textareas.forEach(textarea => {
    textarea.value = sanitizePii(textarea.value);
  });
</script>

Development

A devcontainer has been provided to create a local or Codespaces dev environment. If you submit a pull request, you can run the following to make sure everything works as expected:

npm ci
npm test
npm run lint
npm run format
npm run build
npm run test:build

FAQs

Package last updated on 29 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts