npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pii-mask/cli

v0.2.1

Published

CLI tool for masking PII in files. Wraps @pii-mask/core.

Readme

@pii-mask/cli

Command-line tool for masking PII in CSV, JSON, JSONL, and plain text files. Wraps @pii-mask/core with file I/O, stdin/stdout piping, and detection reports.

Installation

# Global install
pnpm add -g @pii-mask/cli

# Or run directly with npx/pnpm dlx
pnpm dlx @pii-mask/cli data.json --mode redact

Usage

pii-mask [file] [options]

If no file is provided, reads from stdin.

Basic Examples

# Mask a JSON file (default 'mask' mode)
pii-mask users.json

# Redact all PII in a CSV
pii-mask customers.csv --mode redact

# Tokenize and save the token map for later restoration
pii-mask records.json --mode tokenize --token-map-out tokens.json

# Pseudonymize JSONL data
pii-mask events.jsonl --mode pseudonymize

# Generate fake replacement data
pii-mask users.json --mode substitute

Stdin / Stdout

Pipe data through the CLI for use in shell pipelines:

# Pipe JSON through stdin
cat users.json | pii-mask --format json --mode redact

# Pipe from another command
curl -s https://api.example.com/users | pii-mask --format json --mode redact > masked.json

# Inline JSON
echo '{"email":"[email protected]","ssn":"123-45-6789"}' | pii-mask --format json --mode redact
# → {"email":"[REDACTED]","ssn":"[REDACTED]"}

When reading from stdin, use --format to specify the format (defaults to json).

Options

| Flag | Type | Default | Description | |------|------|---------|-------------| | file | positional | — | Input file path. Omit to read from stdin. | | --mode | string | mask | Masking mode: mask, redact, pseudonymize, anonymize, tokenize, substitute | | --output | string | ./masked-output | Output directory for masked files | | --in-place | boolean | false | Overwrite the input file instead of writing to output directory | | --format | string | (auto) | Force input format: csv, json, jsonl, txt. Auto-detected from file extension when using a file. | | --disable | string | — | Comma-separated detector IDs to skip (e.g. --disable phone,dob) | | --only | string | — | Comma-separated detector IDs or categories to run exclusively (e.g. --only email,ssn-us) | | --token-map-out | string | — | File path to persist the token map (tokenize mode) | | --report | boolean | false | Print a detection report to stderr without masking output | | --config | string | — | Path to a .pii-mask.json config file |

Detection Report

Use --report to scan for PII without masking. The report prints to stderr:

pii-mask users.json --report
── PII Detection Report ──────────────────────
  email                4 instance(s)
  ssn-us               2 instance(s)
  phone                3 instance(s)
─────────────────────────────────────────────

Config File

Create a .pii-mask.json config file to set defaults:

{
  "mode": "redact",
  "disable": ["dob", "address"],
  "output": "./sanitized"
}
pii-mask users.json --config .pii-mask.json

CLI flags override config file values.

Supported Formats

JSON

Objects and arrays are walked recursively. All string values are checked against detectors.

pii-mask data.json --mode redact

CSV

The first row is treated as headers. Headers are passed as the key parameter to detectors, enabling key-name heuristics (e.g., a column named "password" triggers the secret-key detector).

pii-mask customers.csv --mode mask

JSONL

Each line is parsed as a separate JSON object.

pii-mask events.jsonl --mode pseudonymize

Plain Text

The entire file content is treated as a single string and processed through freeform text scanning.

pii-mask notes.txt --mode redact

Token Map Persistence

In tokenize mode, the CLI can persist the token map to a file. The map accumulates across multiple runs — existing tokens are preserved and new ones are appended.

# First run
pii-mask batch1.json --mode tokenize --token-map-out tokens.json

# Second run — merges into existing tokens.json
pii-mask batch2.json --mode tokenize --token-map-out tokens.json

The token map file is a JSON object mapping tokens to original values:

{
  "<<PII_a1b2c3d4>>": "[email protected]",
  "<<PII_e5f6a7b8>>": "123-45-6789"
}

Exit Codes

| Code | Meaning | |------|---------| | 0 | Success | | 1 | User error (bad arguments, unsupported format, TTY with no file) | | 2 | Unexpected runtime error |

License

MIT