CLI Commands
Full command reference for the pii-mask CLI.
mask
The primary command. Reads input, masks PII, writes output.
pii-mask <file> [options]Options
| Flag | Description | Default |
|---|---|---|
--mode | Masking mode | mask |
--format | Input format (json, csv, jsonl, txt) | auto-detect |
--output | Output directory path | ./masked-output |
--in-place | Overwrite input file instead of writing to output dir | false |
--disable | Comma-separated detector IDs to disable | none |
--only | Comma-separated detector IDs or categories to run | all |
--regions | Comma-separated ISO country codes (e.g. NG,GB) | all |
--key-name-only | Only mask fields whose key names them as sensitive | false |
--token-map-out | Persist the token map (any format; written 0600) | none |
--report | Print detection report without masking | false |
--config | Path to .pii-mask.json config file | none |
Config file
Create a .pii-mask.json file to set defaults:
{
"mode": "redact",
"disable": ["person-name", "address"],
"output": "./redacted"
}Load it with --config:
pii-mask data.json --config .pii-mask.jsonFlags passed on the command line override config values; defaults never do.
Examples
# Mask a JSON file
pii-mask data.json --mode redact
# Mask CSV, output to file
pii-mask users.csv --mode mask --output ./masked
# Mask in place
pii-mask data.json --mode redact --in-place
# Only run specific detectors
pii-mask data.json --only email,phone
# Tokenize and save token map
pii-mask data.json --mode tokenize --token-map-out tokens.json
# Detection report only (no masking)
pii-mask data.json --report
# Pipe from stdin — JSON, NDJSON or text is detected from the first line
cat data.json | pii-mask --mode tokenize
# Mask a running app's logs line by line
node server.js | pii-mask --mode redactWithin one run the same value always gets the same token or label. NDJSON and text stream line by line; CSV supports quoted multi-line cells and keeps CRLF line endings; masked CSV cells that a spreadsheet would treat as formulas are prefixed with '.
Exit codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Any error; the message is printed to stderr |