Detect Aadhaar, PAN, GSTIN, UPI and other Indian PII in JavaScript
piilite detects every common Indian identity, tax, banking and contact format, checks real checksums, and understands how people in India actually write them.
Which Indian data types does piilite detect?
| Type | Example | How it is checked |
|---|---|---|
AADHAAR | 4918 3726 5017 | 12 digits starting 2-9, Verhoeff checksum; skipped after UTR / order / ref labels |
AADHAAR_VID | 16-digit Virtual ID | Verhoeff checksum + “VID” nearby |
PAN | ABCPS1234K | Structure + valid holder type (4th letter) |
GSTIN | 27AAPFU0939F1ZV | State code + embedded PAN + mod-36 checksum |
UPI_ID | rahul@okhdfcbank | 85+ known UPI handles; any handle when UPI, GPay or PhonePe is mentioned |
PHONE_IN | +91 91234 56780 | Mobile (6-9 start) and landline, every common format, spoken digits |
BANK_ACCOUNT | A/c 50100234567890 | 9-18 digits after an account label or one of 40 bank names |
IFSC | HDFC0001234 | Structure |
VOTER_ID | ABC1234567 | EPIC structure |
PASSPORT_IN | K1234567 | Structure + “passport” label |
DRIVING_LICENSE | MH12 20110012345 | State code + RTO + year + number |
VEHICLE_REG | MH 12 AB 1234, 22 BH 1234 AA | Real state / UT codes, Bharat series |
ABHA | 91-1234-5678-9012 | ABDM health ID format, ABHA address name@abdm |
UAN, ESIC, RATION_CARD | UAN 100123456789 | Label nearby |
OTP, PIN_SECRET | OTP is 482913, UPI PIN 4821 | Label nearby |
DATE_OF_BIRTH | DOB 12/05/1998 | Date after a birth label; real calendar date |
PINCODE | Patna - 800001 | Label, or after one of 220+ cities and states |
NAME | mera naam Priya Verma hai | Intro phrases, labels, titles, S/O, 1,700-name dictionary, 10 languages |
ADDRESS | Flat no 302, MG Road, Pune - 411001 | Labels, house and village markers, landmarks, PIN codes |
LOCATION (opt-in) | Based in: Kotputli, Rajasthan | Profile labels and Town, State pairs |
All examples on this page are fake values.
How do I detect Aadhaar numbers in JavaScript?
Use new Piilite({ types: ["AADHAAR"] }) and call scan(). piilite accepts 12-digit numbers written plain, with spaces or with dashes, and keeps only those that pass the Verhoeff checksum UIDAI uses.
import { Piilite, aadhaar } from "piilite";
const s = new Piilite({ types: ["AADHAAR"] });
s.scan("Aadhaar: 4918 3726 5017"); // [{ type: "AADHAAR", value: "4918 3726 5017", ... }]
s.scan("UTR 412398765432 credited"); // [] (reference numbers are skipped)
aadhaar("491837265017"); // true: checksum only, no text neededNumbers starting with 0 or 1 are never Aadhaar numbers. When the text says “aadhaar” (in English or eight Indian scripts), a number with a typo is still redacted, because the user clearly meant it as one.
How do I validate a PAN number?
A PAN is five letters, four digits and a letter, and its fourth letter must be a valid holder type (P for a person, C for a company, H, F, A, T, B, L, J, G). piilite checks both and skips codes after labels like SKU or model.
import { pan } from "piilite";
pan("ABCPS1234K"); // true
pan("ABCXS1234K"); // false: X is not a holder typeHow does piilite check a GSTIN?
A GSTIN must start with a real state code (01 to 38, 97 or 99), contain a valid PAN, and end with the correct mod-36 check character. piilite verifies all three, so a mistyped GSTIN is not mistaken for a valid one.
import { gstin } from "piilite";
gstin("27AAPFU0939F1ZV"); // trueHow do I detect UPI IDs?
piilite recognises UPI IDs on 85+ known handles such as @okhdfcbank, @ybl, @paytm and @oksbi. Any other name@handle counts when the text mentions UPI, GPay, PhonePe, Paytm or BHIM.
import { redact } from "piilite";
redact("pay rahul.k@okhdfcbank or 9123456780@ybl"); // "pay [UPI_ID_1] or [UPI_ID_2]"Which Indian phone number formats are supported?
piilite detects Indian mobile numbers starting with 6-9 and landlines with STD codes, in every common format. It also understands digits in Indian scripts and numbers spoken in English or Hinglish.
| Written as | Detected |
|---|---|
| 9123456780, 91234 56780, 912-345-6780 | Yes |
| +91 91234 56780, +919123456780, 0091 9123456780, 919123456780 | Yes |
| 091234 56780, 011-23456781 (landline) | Yes |
| ९१२३४५६७८० (Devanagari), ৯১২৩৪৫৬৭৮০ (Bengali) | Yes |
| nine one two three …, nau ek do teen … | Yes |
| 9999999999, 9876543210 (test numbers) | Skipped by default; masked with skipFakeNumbers: false or the strict preset |
How do I detect bank account numbers and IFSC codes?
Bank account numbers are 9 to 18 digits, so piilite only flags them after an account label (A/c, account, khata) or a bank name such as SBI or HDFC. IFSC codes are matched by their structure: four letters, a zero, and six characters.
redact("my SBI A/c 50100234567890, IFSC SBIN0004512");
// "my SBI A/c [BANK_ACCOUNT_1], IFSC [IFSC_1]"How does piilite find Indian names?
piilite finds names from the words around them and from a dictionary of 1,100 first names and 640 surnames from every region, without an AI model.
- Intros: my name is, mera naam … hai, myself, this is, and “my name is” in Hindi, Marathi, Bengali, Punjabi, Gujarati, Odia, Tamil, Telugu, Kannada and Malayalam.
- Labels: Name:, Father's Name:, Candidate:, Beneficiary:, JSON keys like
cust_name. - Titles and relations: Shri, Smt, Dr., Kumari, S/O, W/O, D/O.
- Patterns: initials (K. Ramesh), surname endings (-kar, -wala, -iya), résumé header lines, CSV rows.
Places named after people (Gandhi Nagar, Nehru Place), schools (Vidya Mandir) and tools (MS Excel) are not flagged.
How does piilite find Indian addresses?
piilite finds addresses that start at a label (Address:, Ship to:, mera pata, ঠিকানা:), a house or village marker (Flat no, H.No, Vill., Post, Dist.) or a landmark (near, opp, Sector 15), and ends them at the PIN code.
Addresses after a company name are masked too, because “Engineer at Acme Technologies, 45 Civil Lines, Jaipur” may be a home. Set keepCompanyAddresses: true to leave company-looking addresses such as “Example Technologies Pvt Ltd, Sector 62, Noida” unmasked.
redact("Address: Flat no 302, Sai Krupa Apartment, MG Road, Pune - 411001. Phone 9123456780");
// "Address: [ADDRESS_1]. Phone [PHONE_IN_1]"Can piilite redact cities and locations?
Yes, with the opt-in LOCATION type. It is off by default because a city alone rarely identifies a person and search or matching features often need it.
new Piilite({ include: ["LOCATION"] }).redact("Based in: Kotputli, Rajasthan");
// "Based in: [LOCATION_1]"Last updated · piilite 0.3.0