{
  "id": 5504077,
  "title": "I got tired of hand-rolling PII redaction for logs, so I built it into a small text utility package",
  "url": "https://urgent.news/2026/09/04/i-got-tired-of-hand-rolling-pii-redaction-for-logs-so-i-built-it-into",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-04T05:54:18.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/monsieurnico/i-got-tired-of-hand-rolling-pii-redaction-for-logs-so-i-built-it-into-a-small-text-utility-package-3apl"
  },
  "original_language": "en",
  "account": "One common problem many developers encounter is accidentally exposing sensitive information, like email or phone numbers, in logs or support tickets. Instead of writing a one-off regular expression, they often rely on a full-fledged PII detector or a paid API. However, there's no simple, dependency-free solution that just masks the obvious information.\n\nTo address this need, I added a redact function to textConvert, a small TypeScript text-utility library I maintain. The import statement is simple: \"import { redact } from 'textconvert';\"\n\nThe redact function works by leveraging two existing functions in the library: extractEmails and maskText. extractEmails scans the provided text for email addresses and phone numbers, while maskText partially masks a given string, displaying only a specified number of characters at the end.\n\nFor email addresses, the redact function is straightforward: \"redact('Contact me at jordan@example.com or 555-123-4567'); // Contact me at jo**************** or 55**********\"\n\nWhen redact encounters email and phone numbers, it uses extractEmails to find them, then masks each one with maskText. You can also specify which types of PII to target or customize the mask character: \"redact('Email: jordan@example.com', { types: ['email'] }); // Email: jo****************\"\n\nThe textConvert library offers a wide range of text utilities, including case conversion, validation, and text analysis. However, redact is a valuable addition for smaller projects that need just a handful of text utilities, including PII masking, without the overhead of multiple installs and TypeScript definition files.\n\nTo install textConvert, run \"npm install textconvert\". The package is MIT-licensed and open to contributions. Several issues are tagged as \"good first issue\" if you want to contribute. Feedback is welcome, especially regarding the new redact function.",
  "summary": "Every project eventually hits the same problem: a user pastes their email into a support ticket, or a phone number ends up in a log line, and now you're writing a one-off regex to mask it before it hits storage. You reach for a library — and the options are either a full NLP-based PII detector (Presidio, and friends) that's way more than you need, or a paid API. There's no small, dependency-free…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}