Short answer: to redact PII for an LLM, put a gateway in front of the model that detects personal data in every prompt, swaps each value for a typed placeholder such as `
This guide is for engineers building or reviewing LLM features that handle customer, employee or patient data. It covers the pattern, the methods, Indian identifiers such as PAN, Aadhaar and UPI IDs, safe restoration, and the other places data leaks from an AI system. It is engineering guidance, not legal advice.
What does PII redaction for an LLM actually do?
It limits what the model provider, and anything between you and the provider, can see. The model rarely needs a customer's PAN to draft a polite reply about a failed payment. It needs to know a PAN exists and which is which. A typed placeholder carries that.
The request path looks like this:
- 1. Intercept. Every call to a model goes through one gateway you control. If teams call providers directly, nothing below works.
- 2. Detect. Scan the full assembled prompt: user text, chat history, retrieved chunks, tool results and file text. The assembled prompt usually holds more personal data than the user typed.
- 3. Replace. Swap each detected value for a placeholder that keeps its type and identity, for example `
` and ` `. - 4. Store the map. Write placeholder and original value to a vault keyed by request or session, encrypted, with a short expiry.
- 5. Call the model. The provider sees placeholders only.
- 6. Check the output. Scan the answer for anything that looks like real PII and for placeholders that are not in the map.
- 7. Restore. Replace placeholders with the original values, only where the destination is allowed to see them.
- 8. Log the event, not the content. Record counts by entity type, latency and policy decisions. Do not log the raw prompt.
To map the wider data flow around an AI feature, read our DPDP guide to compliant AI architecture.
Which method should you use: redact, mask, tokenise, hash or encrypt?

Pick per entity type, not once for the whole system. Presidio, an open-source toolkit, ships operators for replace, mask, redact, hash and encrypt, plus a deanonymize engine that reverses encryption. Those map to the choices below.
| Method | What the model sees | Reversible? | Use it when |
|---|---|---|---|
| Redact (remove or `[REDACTED]`) | What the model sees: Nothing of the value | Reversible?: No | Use it when: The model never needs the value or its type, such as a free-text field you do not need to answer from |
| Typed placeholder (` | What the model sees: The type and a stable label | Reversible?: Yes, via your vault | Use it when: The answer must refer back to the value. This is the default for chat, summaries and drafting |
| Partial mask (`xxxx-xxxx-1234`) | What the model sees: The last few characters only | Reversible?: No | Use it when: A human or the model needs to tell two records apart and the full value adds no risk worth taking. Aadhaar is the standard case |
| Realistic surrogate (a fake name or number) | What the model sees: A plausible value of the same shape | Reversible?: Yes, via your vault | Use it when: The task breaks on placeholders, such as a model that must parse a date or phone format. Label surrogates in your logs so nobody mistakes them for real data |
| Salted hash | What the model sees: A fixed token for the same input | Reversible?: No | Use it when: You need to match the same value across records without revealing it. Unsalted hashes of short identifiers can be reversed by trying every candidate |
| Encrypt | What the model sees: Ciphertext | Reversible?: Yes, with the key | Use it when: The value must travel through a system you do not fully control and come back. Key management becomes the control |
Two cautions. First, a vault of placeholders and originals is itself a store of personal data, so it needs access control, encryption, a retention limit and an erasure path. Second, UIDAI's Aadhaar Data Vault FAQ says a hash of an Aadhaar number should not be used as a reference key. Treat hashing as a matching tool, not as a way to make an identifier safe.
How do you detect Indian identifiers such as PAN, Aadhaar and UPI IDs?
Use three detector types together. Format rules catch structured identifiers. Checksums and context cut false matches. A name-entity model catches people, places and organisations that have no fixed format. Then add your own recognisers for anything specific to your product, such as customer IDs, loan account numbers and internal ticket references.
Presidio includes Indian recognisers for PAN, Aadhaar (with a checksum), vehicle registration, voter ID, passport and GSTIN, listed as IN_PAN, IN_AADHAAR, IN_VEHICLE_REGISTRATION, IN_VOTER, IN_PASSPORT and IN_GSTIN. We make no accuracy claim for them or any other detector: they reduce leakage, so test recall on your own data.
| Identifier | What to know | Detection and handling note |
|---|---|---|
| PAN | What to know: Ten alphanumeric characters. The 4th character shows the holder's status (P for an individual) and the 10th is an alphabetic check character (Income Tax Department FAQ) | Detection and handling note: Match the format, then check the 4th character to cut false hits. Replace with a typed placeholder |
| Aadhaar | What to know: A 12-digit number. A masked Aadhaar replaces the first 8 digits with xxxx-xxxx and shows only the last 4 (UIDAI) | Detection and handling note: Use a checksum-aware recogniser. Mask to the last 4 digits before any LLM call. Do not restore the full number into model output unless a system built for it needs it |
| UPI ID (VPA) | What to know: Written as username@pspname, issued by the payment service provider (NPCI UPI circular) | Detection and handling note: It looks like an email address. Detect it with the email rule, then tag by handle if you need to tell UPI from email. Treat both as personal data |
| GSTIN, voter ID, passport, vehicle registration | What to know: Covered by Presidio's recognisers | Detection and handling note: Enable the ones your data contains. Disable the ones it does not, to cut false positives |
| Names, addresses, phone numbers, email | What to know: No single format. Indian names, transliteration and mixed-language text are hard for generic models | Detection and handling note: Use a name-entity model and test it on your own samples, including Hindi in Latin script |
On Aadhaar: the Aadhaar Data Vault rules bind Aadhaar requesting entities. UIDAI's FAQ (version 10, 3 November 2025) says an entity that stores full Aadhaar numbers must keep them only in an Aadhaar Data Vault backed by an HSM, with reference keys used elsewhere. If you are not such an entity, the safe habit is still to mask to the last 4 digits before any LLM call. If you are one, confirm the rules with counsel before an LLM touches the number at all.
How do you restore the original values after the model answers?
Restoration is the riskiest step. The model's answer is untrusted text, and restoring puts real data back into it. Build these rules in:
- Scope the map tightly. One map per request or conversation, never shared across users or tenants. A placeholder from one customer must never resolve in another customer's session.
- Keep numbering stable inside a conversation. `
` must always mean the same person, or the model will confuse them. - Handle streaming. A placeholder can arrive split across chunks, such as `
`. Buffer until a placeholder is complete before restoring. - Expect the model to rewrite placeholders. It may change case, add spaces or invent `
`. Restore only exact matches. For unknown or altered ones, either leave them as they are or flag the answer for review. Never guess. - Restore at the last hop. If the answer feeds a tool call, such as sending an email or updating a CRM, restore only at the tool boundary, and only for fields that tool is allowed to write.
- Do not restore into logs or caches. Store the placeholder version.
- Check the output too. Run the detector on the answer as well as the prompt.
If the model needs the real value to do its job, such as verifying an identity, do not send it to a model at all. Do that step in plain code and give the model only the result.
What does redaction cost you in answer quality?

Some tasks get worse when values are hidden. Greetings go generic, and a model cannot compare two amounts or dates if both are placeholders. Over-redaction, such as hiding every number, can hurt more than it protects.
Handle this by tuning per route, not per company:
- Keep a policy per use case. A support summary may mask names and contact details but keep amounts and dates.
- Replace dates and amounts with surrogates or ranges if the model must reason about them, and keep the original in your vault.
- Run your quality evals with and without redaction and decide from your own results.
Where else does personal data leak from an LLM system?
Redacting the prompt fixes one door. The OWASP Top 10 for LLM Applications 2025 lists Sensitive Information Disclosure as LLM02, and the leaks that matter are rarely only in the prompt. This table covers the controls across the full path. We map them to the OWASP list for reference. We do not claim OWASP compliance, because OWASP is not a certification.
| Leak point | What happens | Control |
|---|---|---|
| Prompts | What happens: Users paste personal data into a chat box, or your code adds a profile and history | Control: Gateway redaction, policy per route, a block rule for the highest-risk types |
| File uploads | What happens: A PDF or image holds an ID card or a bank statement | Control: Extract text first, scan it, and block or redact before the model. Treat images and scanned pages as a separate path that needs OCR |
| Retrieval (RAG) | What happens: A retrieved chunk holds another person's data, or a user sees documents they should not | Control: Apply permissions at retrieval time, and redact at ingest where the original is not needed. See permission-aware RAG |
| Tools, plugins and MCP servers | What happens: A connected tool reads more than the task needs, or sends data onward | Control: Least-privilege scopes, an allow-list of tools, human approval for risky actions. See MCP server security risks |
| Logs and traces | What happens: Your tracing tool stores the full prompt and response | Control: Log metadata by default. Redact before logging when you must keep content. See LLM observability setup |
| Caches | What happens: A provider prompt cache, response cache or semantic cache keeps personal data | Control: Cache the redacted form only, set expiry, and include caches in your erasure process |
| Eval and test sets | What happens: Engineers copy real conversations into test files | Control: Use synthetic or redacted copies, with an owner and retention date |
| Model output | What happens: The answer repeats PII it should not | Control: Output scanning, and a rule on which destinations may receive restored values |
| Provider settings | What happens: Prompts are retained or used for training | Control: Use business or API terms that exclude training, set retention to the shortest the provider offers, and record the setting. See our guide to ChatGPT and AI tools under DPDP |
| Staff using unapproved tools | What happens: Someone pastes data into a personal chatbot account, bypassing your gateway | Control: Find it with a shadow AI audit, then give people an approved route that is easier to use |
On logs: the OpenTelemetry GenAI semantic conventions are an emerging standard, still at Development status. They treat prompt and response content as opt-in, which is the right default. Leave it off in production, or redact first if you turn it on.
Does redaction satisfy the DPDP Act?
Not on its own, and the Act has no category called redaction. The core duties in the Digital Personal Data Protection Act, 2023 start on 13 May 2027. Three points matter for engineering.
- Masked text can still be personal data. The Act defines personal data as any data about an individual who is identifiable by or in relation to that data (Section 2(t)). If a placeholder map or another source lets someone link the text back to a person, treat it as personal data. The Act does not define anonymisation, so do not describe redacted prompts as anonymised.
- Your redaction service is processing. Processing covers any operation on digital personal data, including storage and erasure (Section 2(x)). The detector, the vault and their logs belong on your data map, with an owner, a purpose and a retention period.
- It supports your safeguards. Rule 6(1) of the DPDP Rules, 2025 lists encryption, masking and tokens among the minimum security safeguards. Redaction is one way to show you have thought about that. The Rules do not name it, and whether it is enough depends on your facts.
Redaction does not settle where data goes. Transfer and processor questions remain. Read our guide to DPDP and cross-border AI APIs for that, and take the legal reading to counsel. Where a firm cannot send data out at all, private AI on your own servers is the cleaner answer. See Own Your AI.
How do you test that your redaction works?
- Build a labelled set from synthetic data. Do not use real customer data to test a privacy control. Generate realistic records with fake names, PANs, Aadhaar-shaped numbers and UPI IDs, and mark every sensitive span.
- Measure recall first. A missed PII value is a leak. A false positive costs some quality. Track recall per entity type, not one blended score.
- Test awkward formats. Numbers with spaces or dashes, values split across lines, OCR noise, Hindi names in English letters, values inside JSON, and encoded text.
- Put it in CI. Fail the build if recall on a critical type drops after a change to the model, regex or policy.
- Fail closed. If the detector times out or errors, block the request or fall back to a stricter policy. Never send the raw prompt.
- Watch it in production. Track detection counts by type, latency and block rates. A sudden fall often means a format changed or the detector broke.
Measure the latency redaction adds on your slowest route. Run detectors in parallel and keep the name-entity model warm.
Should you build it, use Presidio, or buy a product?
Presidio is open-source and its documentation includes a worked example of masking LLM calls through a LiteLLM proxy, which makes it a reasonable base for a gateway. Commercial gateways and cloud DLP services exist too. Check whether a tool covers Indian identifiers, lets you add custom recognisers, and runs the detector and vault inside your boundary. A service that sends raw text to a third party to find the PII has moved the problem, not solved it.
If you want help, Mono's AI governance work covers the data-flow review, the gateway policy and the evidence a buyer's security team will ask for. We provide engineering and readiness work. We do not certify anyone, and legal wording goes to your counsel or our partner law firm.
Sources: OWASP Top 10 for LLM Applications 2025 (genai.owasp.org/llm-top-10). Digital Personal Data Protection Act, 2023, Sections 2(t) and 2(x). Digital Personal Data Protection Rules, 2025, Rule 6(1). Presidio documentation: supported entities, anonymizer and LiteLLM masking example (presidio.dataprivacystack.org). Income Tax Department, FAQs on Permanent Account Number. UIDAI, What is Masked Aadhaar, and Aadhaar Data Vault FAQs, version 10, 3 November 2025. NPCI, UPI Consolidated Circular, section 4.1. OpenTelemetry GenAI semantic conventions (github.com/open-telemetry/semantic-conventions-genai). Last reviewed 20 November 2026.
FAQ
What is PII redaction for LLMs?
It is the practice of finding personal data in a prompt, replacing it with placeholders or masked values before the prompt reaches the model, and restoring the originals in the answer afterwards. The mapping stays on your side. It reduces what the provider and your logs can see, but it does not remove your duties as the data holder.
Is redacted data anonymous under DPDP?
Do not assume so. The DPDP Act defines personal data as data about an individual who is identifiable by or in relation to that data (Section 2(t)) and does not define anonymisation. If redacted text can be linked back to a person, including through your own placeholder map, treat it as personal data.
How should I handle Aadhaar numbers in LLM prompts?
Mask to the last 4 digits before any LLM call, matching UIDAI's masked Aadhaar format. UIDAI's Aadhaar Data Vault rules bind entities that store full Aadhaar numbers, and say a hash of an Aadhaar number should not be used as a reference key. If you are such an entity, confirm the position with counsel.
Can Presidio detect Indian PAN, Aadhaar and GSTIN?
Yes, Presidio includes recognisers for IN_PAN, IN_AADHAAR (with a checksum), IN_VEHICLE_REGISTRATION, IN_VOTER, IN_PASSPORT and IN_GSTIN. Treat them as a starting point. Test recall on your own data, add custom recognisers for your identifiers, and do not rely on any detector to catch everything.
Where does the placeholder map live, and for how long?
In an encrypted store you control, scoped to one request or conversation, with a short expiry and no copy in logs or caches. The map holds the original values, so it is personal data and needs access control, a retention period and an erasure path like any other store.
Is redaction enough to stop AI data leaks?
No. Prompts are one path. Data also leaks through file uploads, retrieval, tools and plugins, logs and traces, caches, eval sets, model output, provider settings and staff using unapproved tools. Use redaction together with access control at retrieval, least-privilege tools, log hygiene and a shadow AI review.
