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?

TypeExampleHow it is checked
AADHAAR4918 3726 501712 digits starting 2-9, Verhoeff checksum; skipped after UTR / order / ref labels
AADHAAR_VID16-digit Virtual IDVerhoeff checksum + “VID” nearby
PANABCPS1234KStructure + valid holder type (4th letter)
GSTIN27AAPFU0939F1ZVState code + embedded PAN + mod-36 checksum
UPI_IDrahul@okhdfcbank85+ known UPI handles; any handle when UPI, GPay or PhonePe is mentioned
PHONE_IN+91 91234 56780Mobile (6-9 start) and landline, every common format, spoken digits
BANK_ACCOUNTA/c 501002345678909-18 digits after an account label or one of 40 bank names
IFSCHDFC0001234Structure
VOTER_IDABC1234567EPIC structure
PASSPORT_INK1234567Structure + “passport” label
DRIVING_LICENSEMH12 20110012345State code + RTO + year + number
VEHICLE_REGMH 12 AB 1234, 22 BH 1234 AAReal state / UT codes, Bharat series
ABHA91-1234-5678-9012ABDM health ID format, ABHA address name@abdm
UAN, ESIC, RATION_CARDUAN 100123456789Label nearby
OTP, PIN_SECRETOTP is 482913, UPI PIN 4821Label nearby
DATE_OF_BIRTHDOB 12/05/1998Date after a birth label; real calendar date
PINCODEPatna - 800001Label, or after one of 220+ cities and states
NAMEmera naam Priya Verma haiIntro phrases, labels, titles, S/O, 1,700-name dictionary, 10 languages
ADDRESSFlat no 302, MG Road, Pune - 411001Labels, house and village markers, landmarks, PIN codes
LOCATION (opt-in)Based in: Kotputli, RajasthanProfile 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.

js
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 needed

Numbers 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.

js
import { pan } from "piilite";
pan("ABCPS1234K"); // true
pan("ABCXS1234K"); // false: X is not a holder type

How 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.

js
import { gstin } from "piilite";
gstin("27AAPFU0939F1ZV"); // true

How 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.

js
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 asDetected
9123456780, 91234 56780, 912-345-6780Yes
+91 91234 56780, +919123456780, 0091 9123456780, 919123456780Yes
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.

js
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.

js
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.

js
new Piilite({ include: ["LOCATION"] }).redact("Based in: Kotputli, Rajasthan");
// "Based in: [LOCATION_1]"

Last updated · piilite 0.3.0