I got tired of hand-rolling PII redaction for logs, so I built it into a small text utility package
Description and use
A lightweight TypeScript library that automatically masks emails and phone numbers in logs, eliminating the need for manual regexes or heavy NLP tools.
Problem
Developers often need to mask emails and phone numbers in logs or support tickets, but existing solutions are either heavyweight NLP libraries or paid APIs, leaving a gap for a lightweight, dependency-free utility.
Outcome
The library offers a lightweight, zero-dependency solution for masking emails and phone numbers in free-form text, reducing manual regex work and improving consistency.
Workflow
- 1. Install textconvert via npm.
- 2. Import
redactfrom the library. - 3. Call
redactwith the text to mask, optionally passing options for types or maskChar. - 4. Receive the masked string with PII replaced by asterisks or custom characters.
Evidence
It scans free-form text — not just a single known value — and masks every email and phone number it finds, in place, leaving everything else untouched.
redact finds matches with extractEmails (and an equivalent internal scanner for phone numbers), then masks each one with maskText.
- Record date: 2026-09-09T22:30:58.200Z