India-first PII detection and masking for JavaScript
piilite finds and masks personal data such as Aadhaar, PAN, GSTIN, UPI IDs, +91 phone numbers, Indian names and addresses before it reaches your logs, your database or an AI model. No AI model, no network calls, no dependencies.
npm install piilite
# or
pnpm add piilite
yarn add piilite
bun add piilite- 28.0 KB gzipped
- Zero dependencies
- ESM + CommonJS + TypeScript
- Node 18+, browsers, Bun, Deno
- MIT licensed
Try it live
Edit the text and watch piilite mask it as you type. It runs in your browser; nothing is uploaded.
Quick start
Create a Piilite instance and call detect(). You get the redacted text, every detection with its position, and a map to restore the originals.
import { Piilite } from "piilite";
const shield = new Piilite();
const { redacted, redactionMap } = shield.detect(
"Myself Ankit Kumar Gupta, call 9123456780 or pay ankit@okhdfcbank. PAN ABCPS1234K, OTP is 482913"
);
console.log(redacted);
// Myself [NAME_1], call [PHONE_IN_1] or pay [UPI_ID_1]. PAN [PAN_1], OTP is [OTP_1]What is piilite?
piilite is a free, open-source JavaScript library for PII detection and data masking, built for Indian data. It checks real checksums, understands Hinglish and nine Indian scripts, and is made for apps that send user text to large language models.
Real checksums
Verhoeff for Aadhaar, mod-36 for GSTIN, Luhn for cards (incl. RuPay), mod-97 for IBAN. Random numbers are not flagged.
Writes like India writes
Hinglish (“mera naam … hai”), Indic digits (९८७६…), spoken numbers, disguised emails, S/O and W/O.
Built for LLM apps
Consistent placeholders, fuzzy restore(), streaming redaction for token streams, redactObject() for chat payloads.
Presets
DPDP Act 2023, KYC, fintech, PCI, healthcare, HR, GDPR, HIPAA and secrets, in one option.
Tiny and fast
28.0 KB gzipped, about 1.5 ms for a 1 KB message, tested against slow-regex (ReDoS) attacks.
Drop-in for OpenRedaction
Same detect() result shape and custom patterns, plus an optional bridge to its 110 global ID types.
What personal data does piilite detect?
piilite detects 45+ types of personal data: every common Indian ID and financial format, phone numbers, emails, names, addresses, cards, IP addresses and API keys. See all Indian PII types.
| Group | Types |
|---|---|
| Indian IDs | Aadhaar, Aadhaar VID, PAN, GSTIN, TAN, CIN, voter ID, passport, driving licence, vehicle number, ration card, ABHA, UAN, ESIC |
| Money | UPI ID, bank account, IFSC, cards (RuPay, Visa, Mastercard, Maestro, Amex), CVV, expiry, IBAN, SWIFT |
| Contact | +91 mobiles and landlines, international phones, email (also disguised), social and coding profiles |
| People and places | Names (10 Indian languages), addresses, PIN codes, date of birth, opt-in city / location |
| Secrets | OTPs, UPI / ATM PINs, passwords, API keys (OpenAI, AWS, Razorpay, Stripe, GitHub …), JWTs, private keys |
How accurate is piilite?
On a held-out benchmark of 480 samples, piilite caught 84.3% of personal data with 99.7% precision, against 45.7% and 76.7% for OpenRedaction. See the full benchmark.
How do I use piilite with an AI model?
Redact the prompt, send the redacted text to the model, then restore the answer. The model never sees the real values.
const { redacted, redactionMap } = shield.detect(userMessage);
const answer = await callYourModel(redacted); // the model sees [NAME_1], [PHONE_IN_1] ...
const reply = shield.restore(answer, redactionMap); // real values only on your serverRead the LLM guide for streaming, chat payloads and Express middleware.