The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the MaskFlow PII proxy listing page.
Stop Indian PII from ever reaching an LLM.
Aadhaar, PAN, GSTIN, UPI, IFSC, ABHA, Indian names and addresses — detected and replaced with reversible, typed placeholders before a prompt leaves your process, restored in the response. 28 entity types, checksum-validated where a public checksum exists, MIT-licensed, runs entirely on your own infrastructure.
India's DPDP Act sets a compliance deadline of 13 May 2027, with penalties of up to ₹250 crore for a breach where the required safeguards weren't in place. Every prompt sent to an LLM provider is a potential data-sharing event — and general-purpose PII tools weren't built to recognize Aadhaar, PAN, GSTIN, UPI VPAs, IFSC codes, ABHA health IDs, or Indian names and addresses reliably. Presidio already owns generic PII and is more mature everywhere else; MaskFlow exists specifically to close that gap, with accuracy that's measured and published, not asserted. See MaskFlow vs. alternatives.
For a one-line wrapper around your actual LLM call, or session-scoped masking across a multi-turn
agent (same value → same token for as long as the session is open), see
packages/maskflow-sdk/README.md.
Span. Start/end offsets, entity type, confidence, which recognizer
produced it, whether a checksum validated it, and a human-readable explanation trail. Run
maskflow explain "<text>" (from maskflow-cli) to see that trail for any input, span by span
— including near-misses that fell just below threshold and what config change would catch them.<AADHAAR_1>, <EMAIL_1>, ... — the
same value gets the same token within a session, and if the input text already contains
something that looks like a placeholder, a nonce suffix (<AADHAAR_1_a4f9>) is used instead so
a real placeholder is never ambiguous with attacker-controlled input.maskflow-pack-intl and maskflow-pack-india are just two
"maskflow.recognizers" entry-point plugins sharing one memoised analysis context — write and
register your own the same way. See docs/custom-recognizers.md.Regex/checksum-based recognizers can also scrub your application's own logging calls — not just
text passed through mask() — closing the gap where a raw value gets logged before it's ever
masked:
Opt-in only; importing maskflow_core never touches global logging state on its own. It doesn't
cover NER-only entity types (bare names/addresses) or exc_info tracebacks — see
docs/logging.md for the exact boundary.
Going forward, mask() keeps PII out of your prompts. But the DPDP audit asks a backward-looking
question first: what has this system already sent to a third-party LLM? maskflow scan answers
it. It reads your historical LLM traffic — a JSONL/CSV export, a recursive directory, an S3
archive, a Postgres table, or the Langfuse / Helicone / LangSmith API — streams it through the
same detection with bounded memory (parallel, resumable), and writes one self-contained HTML
report: a single headline number, breakdowns by entity type / provider / model / time, a
severity ranking with a plain-English "why this matters" per row, masked excerpts only (never
a raw value), and a DPDP Rule 6 mapping appendix. Also --format json|csv. Runs entirely locally
— the API sources only read from your own account, nothing is transmitted.
Also ships as a standalone binary (mac/linux/windows, no Python — pattern pass only) and a
GitHub Action that can fail a build over a PII-exposure threshold. A
runnable 60-record synthetic example is in
packages/maskflow-cli/examples/; full reference,
including the Rule 6 mapping, in docs/scan.md.
maskflow-gateway is a drop-in OpenAI/Anthropic-compatible proxy. Point your existing client's
base URL at it and PII is masked before every request reaches the provider and restored in the
response — streaming included (a <PERSON_NAME_1> split across SSE chunks is stitched back
together; fuzz-tested at every byte boundary). Tool-call arguments are walked as JSON; multi-turn
token identity is kept in Redis (AES-256-GCM at rest).
Full reference in packages/maskflow-gateway/README.md and
docs/gateway.md.
Already running a LiteLLM proxy? maskflow-litellm is a
custom guardrail — no separate service. It masks PII (Indian identifiers included) before a
request leaves the proxy and restores it in the response, streaming and tool calls included.
Full reference in packages/maskflow-litellm/README.md and
docs/litellm-guardrail.md.
maskflow-langchain is a drop-in for
langchain-experimental's Presidio
anonymizer — same .anonymize() / .deanonymize() / .deanonymizer_mapping — so an existing
chain migrates by changing one import. The deanonymizer is a streaming-aware Runnable (a
placeholder split across streamed chunks is stitched back), and there's an optional leak-guard
callback that fails a call closed if PII reaches the model.
Full reference in packages/maskflow-langchain/README.md
and docs/langchain.md.
maskflow-llamaindex gives a LlamaIndex RAG pipeline two components and an unmask helper.
MaskflowNodePostprocessor is a drop-in for llama_index.core.postprocessor.PIINodePostprocessor
(same __pii_node_info__ contract) that masks retrieved context before the synthesizer, with no
LLM call. MaskflowIngestionTransform masks node text at ingestion so raw PII never reaches the
vector store. unmask_response() / MaskflowQueryEngine restore the real values in the answer.
Full reference in packages/maskflow-llamaindex/README.md
and docs/llamaindex.md.
maskflow-mcp is a Model Context Protocol proxy. Put it in
front of any MCP server and PII in outbound tools/call arguments is masked before it reaches the
tool, results are unmasked on the way back, and placeholders stay consistent for the whole agent
run. Agent tooling is where PII leakage is least examined; this is a drop-in shim that stops the
real values at the boundary.
Full reference in packages/maskflow-mcp/README.md and
docs/mcp.md.
maskflow-evidence emits a metadata-only record of what was masked — entity type, count,
recognizer, action, versions — and never a value, a placeholder, or the mapping. Off by default;
one line in .maskflowrc turns it on, to a self-hosted sink (stdout / file / syslog / webhook /
OTLP). The gateway emits automatically when enabled; maskflow explain --evidence does it for a
single run.
That no event field can carry free text is enforced in CI. Full reference in
docs/evidence.md. Compliance-control mapping and signed accuracy
attestations (R5 items 2–3) are still being validated with practitioners and are not yet part of
this layer.
Drop a .maskflowrc (TOML/YAML/JSON) in your project to adjust entity thresholds, disable an
entity, add a custom regex-based entity, exclude specific values, or change the substitution
strategy per entity (replace / redact / mask / hash / surrogate — the last swaps in a
plausible fake value drawn from reserved/test-only ranges, e.g. RFC 2606 example domains or
publicly documented payment-industry test card numbers, instead of a placeholder token).
mask()/mask_and_call()/session() all pick it up automatically; no .maskflowrc anywhere
behaves exactly as before this existed:
See docs/configuration.md for the full schema and precedence rules.
maskflow-sdk and maskflow-cli both bundle maskflow-pack-intl and maskflow-pack-india —
installing either gets you all 28 types below with no extra install step.
International (12 types) — maskflow-pack-intl:
| Type | How |
|---|---|
| Regex | |
| Phone | Regex |
| SSN | Regex + area-code validation |
| Credit card | Regex + Luhn checksum |
| IP address (v4/v6) | Regex |
| AWS access key | Regex |
| API key / generic secret | Regex |
| JWT | Regex |
| IBAN | Regex + mod-97 checksum |
| Street address | Regex |
| Person name | spaCy NER |
| Date of birth | spaCy NER + keyword context |
Indian (17 types, the moat) — maskflow-pack-india:
| Type | How |
|---|---|
| Aadhaar (UID + VID) | Regex + Verhoeff checksum |
Aadhaar (masked display form, e.g. XXXX XXXX 9012) | Regex, unvalidated, needs context |
| PAN | Regex + holder-category structural check (no public final-letter checksum) |
| GSTIN | Regex + state-code range + embedded-PAN check + base-36 checksum |
| IFSC | Regex + bank code against a bundled RBI code list |
| UPI VPA | Regex + PSP handle against a bundled NPCI handle list |
| Indian mobile number | Regex, full confidence with a +91/0 prefix, needs context otherwise |
| PIN code | Regex, unvalidated, needs context (pin/pincode/state name/address) |
| Voter ID (EPIC number) | Regex, structural only (no public checksum) |
| Indian passport number | Regex, structural only (no public checksum) |
| Indian passport MRZ block | Regex + 4 ICAO 9303 check digits |
| Driving licence | Regex + state RTO code against a bundled code list |
| Vehicle registration | Regex + state RTO code against a bundled code list |
| ABHA number (health ID) | Regex, unvalidated, needs context |
| ABHA address | Regex + domain (abdm/sbx) check |
| Bank account number (India) | Regex, unvalidated, needs context (account/a/c/acct) |
| Person name (Indian) | Gazetteer (name corpus) + structural (honorifics, relational markers, initials, form fields) + spaCy NER agreement boost |
| Indian address | Gazetteer (554+ Indian cities/places) + structural (unit markers, landmark-relative phrasing, locality patterns) |
(PERSON_NAME is one shared entity type produced by both packs' layers, so 12 + 17 − 1 shared = 28
unique types total.)
@maskflow/detection on npm is a TypeScript port of the 10 pure regex/structural intl types
(email, phone, SSN, credit card, IP, AWS key, API key, JWT, IBAN, street address) — same API
shape as the Python SDK, tested against the same fixtures so both stay accuracy-matched.
PERSON_NAME/DATE_OF_BIRTH (need spaCy NER) and the India pack's checksum-validated types are
Python-only — @maskflow/detection is a deliberately narrow browser/Node helper, not a second
full engine. See packages/maskflow-js/README.md.
| MaskFlow | Presidio | mask-privacy | |
|---|---|---|---|
| Indian identifiers with checksums | Aadhaar, PAN, GSTIN, IFSC, UPI (in maskflow-sdk) | No | No |
| Session-consistent tokens (unmask later) | Yes | Via custom anonymizer config | Yes, today |
| NER | spaCy | spaCy, Stanza, transformers | Regex-based, no NER |
| Breadth / maturity | Narrow, early (28 types) | Broad, mature (Microsoft-backed, years of production use) | Narrow, early |
| License | MIT | MIT | Varies by package |
| Languages | Python + TypeScript (regex layer) | Python, multi-language via configurable NLP models | JS/TS |
Presidio is ahead on breadth and maturity. If you need broad, battle-tested coverage today, use it. MaskFlow's bet is Indian-identifier accuracy and a reversible mask/unmask flow that's simpler to drop into a single, provider-agnostic call.
Real numbers, not vendor claims — including results where competitors beat us. Scored on
indiapii-v1.0, 2000 synthetic, checksum-valid
documents (Aadhaar/PAN/GSTIN pass the same validity math the real formats use), against stock
Presidio, Presidio with two hand-added Aadhaar/PAN recognizers, and mask-privacy. F1 below is
partial-overlap matching (exact-character matching is too strict for multi-token spans like
addresses — see the full report for both).
| Entity | MaskFlow | Presidio (stock) | Presidio + custom | mask-privacy |
|---|---|---|---|---|
| GSTIN / IFSC / UPI VPA | 100% | not supported | not supported | not supported |
| AADHAAR | 98.4% | not supported | 96.6% | not supported |
| PAN | 100% | not supported | 100% | not supported |
| Indian mobile number | 99.0% | 94.9% | 94.9% | 41.9% |
| Person name | 47.3% | 30.4% | 30.4% | 37.7% |
| Indian address | 43.3% | 48.2% | 48.2% | 57.9% |
Indian address is the one row above where a competitor is ahead — our gazetteer still has room to
grow, and we're not hiding that. Full per-entity breakdown (all 17 types), strict-vs-partial
matching, and latency/memory numbers:
bench/reports/indiapii-v1.0/results.md. Reproduce with
uv sync --group bench && uv run python -m bench.indiapii.harness run; harness source in
bench/indiapii/harness/.
Openly not done yet, so you know what you're signing up for:
maskflow-gateway hardening: more provider schemas, a Redis-cluster session backend, and
first-class OpenTelemetry traces.docs/configuration.md,
docs/custom-recognizers.md,
docs/scan.md, docs/dpdp-rule6.md,
docs/agent-sessions.md, docs/logging.md,
docs/gateway.md,
docs/litellm-guardrail.md,
docs/langchain.md,
docs/llamaindex.md,
docs/mcp.md,
docs/data-refresh.md