NoPII

Techniques to Protect PII in LLM Applications and How to Choose the Right One

The most effective techniques to protect PII in LLM applications combine detection, data minimization and reversible tokenization, backed by access controls and clean logs. Redaction, masking, encryption and self-hosting each fit narrower jobs.

AK Abhilash Kumar Dec 3, 2026 22 min read
On this page

    Enigma Vault

    Secure your cards.
    Protect your data.
    Keep it out of your AI.

    Data tokenization that keeps your applications working, so a breach exposes nothing worth stealing.

    • Free Lite tier, no contract
    • PCI DSS Level 1, SOC 2 Type II
    • Billed through AWS Marketplace
    Request a demo

    The most effective techniques to protect PII in LLM applications combine detection, data minimization and reversible tokenization, backed by access controls and clean logs. Redaction, masking, encryption and self-hosting each fit narrower jobs.

    Most teams meet this problem one technique at a time. A regex script appears first, then a name detector, then a debate about hosting a model in-house. Each one covers a slice of what reaches the provider, and the gaps surface later in tool results, in logs and in replies that come back with blanks where names should be.

    The techniques also behave very differently once a model has to reason over the data. Some remove information for good, some hide it behind a key, and one family swaps values for stand-ins the model can still work with. Each technique gets its own section below, followed by a side-by-side comparison and a clear recommendation on which one to choose.

    What Are the Main Techniques to Protect PII in LLM Applications

    The main techniques to protect PII in LLM applications are detection, data minimization, access controls, redaction, masking, format-preserving encryption, pseudonymization, reversible tokenization, synthetic data and self-hosted models.

    Every technique starts from the same fact. Each prompt your application sends to a model provider is a data transfer, and personal data inside it falls under that provider's logs, retention and jurisdiction. The techniques differ in what they do to the data before, during and after that transfer.

    TechniqueHow it protects PII
    PII detectionFinds names, IDs, card numbers and secrets in text so other techniques can act on them
    Data minimizationKeeps fields out of the request when the task doesn't need them
    Access controlsLimits which people and systems can see real values
    RedactionDeletes a value and leaves a fixed placeholder behind
    MaskingHides part or all of a value, sometimes with a fake value of the same shape
    Format-preserving encryptionEncrypts a value so the output keeps the original length and format
    PseudonymizationReplaces identifiers with references that can only be linked back using separate information
    Reversible tokenizationSwaps each value for a consistent token held in a vault, then restores it in the reply
    Synthetic dataGenerates realistic records that describe no real person
    Self-hosted modelsKeeps the model on your own infrastructure, so no outside provider receives requests

    PII doesn't only arrive in the message a user types. It also travels in system prompts, in what flows into and out of tool calls, in earlier conversation turns, streamed replies, documents sent for embeddings, and the logs and traces that capture all of it. A technique that covers one of these and misses the rest leaves real gaps. A clear grasp of types of personally identifiable information is the starting point for deciding what each technique has to catch.

    PII Detection Techniques That Every Protection Method Depends On

    Detection techniques find PII using patterns, checksums, named entity recognition, nearby labels and secret signatures. Every protection method depends on them, because a value that isn't detected can't be redacted, masked or tokenized.

    Redaction, masking and tokenization all act on what detection finds. When detection misses a value, every downstream technique misses it too. Most production systems combine several methods:

    Detection methodHow it finds PIIBest atWeak spot
    Pattern matchingMatches known shapes such as email formats, phone layouts and card number lengthsStructured values with predictable formatsValues written in unusual formats or split across lines
    Checksum validationRuns the math built into some identifiers, such as the Luhn check on card numbersSeparating real IDs from random digit stringsIdentifiers that have no checksum
    Named entity recognitionUses a language model to spot names, places and organizations in free textPerson names and locationsNames in languages or scripts the model wasn't trained on
    Label and context detectionLooks for an identifying label like TFN or NRIC placed right before a numberIDs that look like ordinary numbers on their ownValues that appear without their label
    Secret signaturesMatches credential formats, from cloud and model API keys to private keys, connection strings and auth tokensCredentials pasted into logs and support chatsCustom or internal secret formats

    Two settings shape how well detection performs in practice. A confidence threshold, often called detection sensitivity, decides how sure the detector must be before it acts. Too low, and ordinary words get replaced. Too high, and real values slip past. Custom terms let you add identifiers specific to your business, such as employee numbers or matter IDs, which no off-the-shelf detector knows about.

    Detection has limits too. Coverage for regional IDs varies widely between tools, names in some scripts are harder to recognize, and text that describes a medical condition or a debt can be sensitive without containing a single identifier. Any serious approach to PII protection in LLM apps handles detection as a layer to test and tune, never as a solved problem.

    Data Minimization and Access Controls as the Base Layer of PII Protection

    Data minimization keeps unneeded fields out of every request, and access controls limit who can see real values. Together they shrink what needs protecting before any other technique runs, so every later layer has less to catch.

    Data Minimization

    The safest PII is the PII that never enters the request. Minimization means sending a model only the fields its task needs, narrowing retrieval queries and keeping attachments such as IDs or bank statements out of prompts.

    Take an assistant that summarizes client contracts. A summary of payment terms needs the clauses, the amounts and the dates. It doesn't need the client's home address, the signatory's passport number or the email thread the contract arrived in. Removing those fields costs nothing in answer quality and removes a whole category of risk. Minimization can't handle sensitive meaning inside the text itself, which is why it works as a base layer beneath the other techniques.

    Access Controls and Least Privilege

    Access controls decide who and what can touch real values once they exist in your systems. In an LLM application, that usually covers:

    • Service keys scoped so each application can only call the actions it needs
    • Separate workspaces for each tenant or business unit, so settings and data never mix
    • Roles for administrators and members, with changes to detection settings limited to a few people
    • Least privilege for staff, so support agents see what their job requires and nothing more

    Reveal Rules and Log Hygiene

    When values are protected by a reversible technique, the next question is who can turn them back into real data. Sensible reveal rules return real values only to the user who created them, give everyone else access through time-limited grants with a recorded reason, and refuse reveals when the system checking those rules is unavailable.

    Logs need the same care. Tracing tools and audit logs capture request bodies by design, so they should hold only protected content and masked values. Retention rules then decide how long protected values live, and a purge process removes them when a deletion request arrives.

    When LLM features grow into AI agents: agents retrieve records, hold cards or files and take actions across many steps, which widens the access question considerably. Enigma AI Vault extends these controls to agents, keeping release decisions for real values outside the model.

    Redaction and Masking Techniques for LLMs and Where Each One Breaks

    Redaction deletes a value and leaves a placeholder, whereas masking hides part of a value or swaps in a fake one of the same shape. Both are one-way techniques that protect data by removing information the model may need.

    Redaction

    Redaction replaces each detected value with a fixed label. It is the simplest technique to build and the easiest to explain to an auditor.

    Original: Send the signed NDA to Marcus Lee and copy his counsel, Dana Ortiz, at dana.ortiz@example.com.
    Redacted: Send the signed NDA to [REDACTED] and copy his counsel, [REDACTED], at [REDACTED].

    The model can no longer tell the two people apart, and the reply can't include either name because nothing is kept to restore. A blank sitting beside a label like SSN also raises the chance of a refusal. Redaction fits values the model never needs and the user never expects back, such as a card number pasted into a complaint about delivery times.

    Partial and Format-Preserving Masking

    Masking keeps some of the original visible or replaces the value with a realistic fake. Common variants look like this:

    Masking styleOriginalMasked
    Partial masking4111 1111 1111 1234XXXX XXXX XXXX 1234
    Partial maskingdana.ortiz@example.comd***@example.com
    Format-preserving maskingDana OrtizLeah Brandt
    Format-preserving masking415-555-0142628-555-0199

    Partial masking suits screens and reports where staff need to confirm a record without seeing all of it. Format-preserving masking keeps downstream code working, since an email still looks like an email. Inside LLM requests, both have limits. Partial values still leak fragments, and fake values can confuse a model if the same person gets a different fake name in each request.

    Generalization

    Generalization replaces an exact value with a range or category. An age of 34 becomes 30 to 39, a street address becomes a city, and a salary becomes a band. It works well for analytics-style questions where precision doesn't matter, such as asking a model to describe trends across a client base. It breaks down for any task about a specific person, and careless bands can still single someone out in a small group. Teams moving beyond basic masking data in LLM requests usually find these one-way techniques hit their limits as soon as a conversation involves several people.

    How Format-Preserving Encryption Protects PII in LLM Applications

    Format-preserving encryption scrambles a value with a secret key while keeping its length and character set, so a card number stays sixteen digits. Anyone holding the key can decrypt it, which makes key control the real security boundary.

    Format-preserving encryption, often shortened to FPE, applies a keyed cipher that outputs a value in the same format as the input. Standardized modes such as FF1 are commonly used for structured fields like card numbers, account numbers and national IDs.

    Original card number:  4111 1111 1111 1111
    FPE output (example):  7294 5302 8817 6643

    The output fits the same database column and passes the same format checks, which is why FPE is popular when older systems can't accept a different field shape. The same key that encrypts the value can decrypt it.

    How it compares in practice:

    • Strong fit: structured fields in databases, payment systems and file exports, where schemas are fixed and changing field formats is expensive.
    • Weaker fit inside LLM prompts: an encrypted card number still looks like a card number, so models may treat it as real, and labels around it can still trigger refusals.
    • Key exposure: any application holding the key can see plaintext again, so the key management behind it sets the real level of protection.
    • Free text: FPE needs to know exactly where a value starts and ends, so it relies on detection as heavily as any other technique when values sit inside sentences.

    Encryption remains essential for data at rest and in transit. On its own, though, it doesn't stop an authorized application from retrieving plaintext, and it doesn't reduce who receives the data in the first place.

    How Pseudonymization and Reversible Tokenization Protect PII in LLMs

    Pseudonymization replaces identifiers with references that need separate information to link back, whereas reversible tokenization is one specific way to do it, holding every original value in a vault and restoring it on demand.

    Pseudonymization

    Pseudonymization is a broad category. The defining idea is that the data can no longer be tied to a person without extra information kept somewhere else. Two common approaches show up in LLM applications.

    Keyed hashing runs each value through a hash function with a secret key, so the same name always produces the same output. It keeps references consistent across requests, but it is one-way, so the original can't be restored in a reply. Unkeyed hashes are weaker still, since short values such as phone numbers can be guessed by hashing every possible number.

    Session placeholders swap values for labels such as PERSON_1 and PERSON_2, and keep the mapping for the length of one conversation. They restore values within that session, then forget the mapping, so the same customer gets a new label the next day.

    Reversible Tokenization

    With reversible tokenization, each sensitive value becomes a token whose mapping sits in a secure vault. In the format the NoPII page uses, a request looks like this:

    Before: Send the signed NDA to Marcus Lee and copy his counsel, Dana Ortiz, at dana.ortiz@example.com.
    After:  Send the signed NDA to [NAME: Lm8Qa2v] and copy his counsel, [NAME: Kt4Pw9s], at [EMAIL: Dx7Hn3c].

    Four properties make the approach work when PII is sent to an LLM:

    1. Deterministic tokens give the same value the same token every time, so Marcus stays one person from the first message onward.
    2. Round-trip detokenization swaps tokens back for real values before the reply reaches your application, so users read normal answers.
    3. Context phrase neutralization replaces labels that trigger refusals, so a model sees ID number where the text said social security number, account number in place of credit card number and date where it said date of birth.
    4. Blocking on failure stops a request when tokenization can't run, and a restore that fails leaves the token in the reply, so an error never reveals the original.

    How the Two Differ

    Point of comparisonKeyed hashingSession placeholdersReversible tokenization
    Real value restored in repliesNoWithin one sessionYes, under reveal rules
    Same reference across sessionsYesNoYes
    Location of the mappingNowhere, only the keyApplication memorySecure vault
    Handling of deletion requestsHard, outputs stay linkableMapping expires on its ownTokens purged at the vault

    Tokenized data still counts as pseudonymous, because whoever controls the vault can link it back. That link is what makes restoring values possible, and it is also why the vault needs strict controls. For a broader primer, see how tokenization works and why a token carries none of the value it replaces.

    When Synthetic Data and Self-Hosted Models Fit PII Protection for LLMs

    Synthetic data suits testing, evaluation and fine-tuning where no real person needs to appear, and self-hosted models suit isolated environments. Neither replaces protection for live requests that must answer questions about real customers.

    Synthetic Data

    Synthetic data generators produce records that look and behave like real ones without describing any real person. Teams use them to build test suites, evaluate prompts before launch, and create fine-tuning sets without copying customer records into training data. Fidelity is the weak point. A synthetic contract set may miss the odd clauses and formatting quirks that real contracts contain, so results need checking against real samples under controlled access. Synthetic data also can't help a live assistant answer a question about an actual client, because the whole point of that request is the real client.

    Self-Hosted Models

    Running an open model on your own infrastructure means requests never reach an outside provider. That takes provider logs and retention out of the equation entirely, which matters in air-gapped or highly regulated settings. The trade-offs are real:

    BenefitCost
    No third-party provider receives promptsHardware, scaling and model updates become your responsibility
    Full control over where data and logs liveOpen models may trail frontier models on complex reasoning tasks
    Fits environments with no outside network accessPII still lands in your own logs, caches and vector stores

    Self-hosting moves the boundary without removing the need for minimization, access controls and clean logs inside your own walls. Many teams also want the strongest available models for customer-facing features, which usually means a hosted provider.

    Differential Privacy

    Differential privacy adds carefully calibrated noise to statistics or training processes so no single record can be singled out from the results. It belongs in analytics and model training, where you care about patterns across many people. It doesn't fit live LLM requests, since an assistant summarizing a contract needs the actual clauses of the actual contract.

    How PII Protection Techniques for LLM Applications Differ

    Redaction, masking and hashing remove information for good, whereas encryption and tokenization can be reversed. With hosted models, only tokenization keeps reasoning intact while the provider gets nothing usable.

    The matrix below compares every technique on the points that matter most when PII is headed for an LLM:

    TechniqueReversibilityModel reasoningWhat the provider receivesBest fitAvoid when
    Data minimizationNot neededIntact for the fields keptOnly the fields the task usesEvery request, as a first stepNever, it always helps
    RedactionNoneWeakenedFixed placeholdersValues the model and user never needSeveral people appear in one thread
    Partial maskingNonePartly keptFragments of real valuesScreens and reports for staffFragments still identify someone
    Format-preserving maskingNonePartly keptFake but realistic valuesTest data and downstream codeConsistency across requests matters
    GeneralizationNoneTrends onlyRanges and categoriesAnalytics questionsTasks about one specific person
    Format-preserving encryptionPossible with the keyPartly keptEncrypted values in the original formatStructured fields in fixed schemasFree text inside prompts
    Keyed hashingNoneConsistent references onlyConsistent one-way valuesLinking records across analyticsUsers expect real values in replies
    Reversible tokenizationUnder reveal rulesFully intactTokens that reference nothingLive LLM features on customer dataTasks needing the literal value
    Synthetic dataNot applicableIntact on fake recordsGenerated recordsTesting, evaluation, fine-tuningAnswering questions about real people
    Self-hosted modelsNot applicableDepends on the modelNothing, no provider involvedIsolated or air-gapped environmentsFrontier model quality is required
    Differential privacyNot applicableAggregates onlyNoisy aggregatesAnalytics and trainingAny task about one record

    Look across the rows and the trade-off becomes clear. Techniques that remove information protect the provider boundary but weaken the answer. Techniques that keep information usable, such as encryption, often leave something the provider or the model can misread. Choosing well means weighing those trade-offs against what each feature does, and deciding where data redaction for AI still makes sense alongside more capable options.

    Why Reversible Tokenization Should Be Your Choice to Protect PII in LLMs

    Reversible tokenization should be your default whenever PII has to reach an LLM, since the provider gets only meaningless tokens, the model keeps reasoning and replies come back with real values, with requests blocked when protection fails.

    Why Tokenization Wins When PII Goes to an LLM

    For features that send customer data to a hosted model and need useful answers back, tokenization is the only technique that solves both sides of the problem at once. Here is why it comes out ahead:

    1. Nothing usable reaches the provider: tokens reference nothing outside your vault, so provider logs and retention hold no real identifiers. Partial masking and generalization still pass fragments of the truth along.
    2. Model reasoning survives: deterministic tokens keep different people distinct and each person consistent, which holds long conversations and chained reasoning together. Redaction collapses everyone into one placeholder.
    3. Users get real answers: round-trip detokenization restores names, emails and account references before the reply reaches your application. Redaction and hashing leave blanks.
    4. Refusals drop: context phrase neutralization removes the labels that make models decline scrubbed requests.
    5. Plaintext lives somewhere else: tokenization removes plaintext from ordinary systems, while encryption leaves it one key away for any application that holds that key.
    6. You keep your choice of model: tokenization sits in front of any hosted provider, so teams don't have to trade frontier model quality for privacy the way self-hosting often demands.
    7. Failures stay safe: a tokenization layer that blocks the request on error never sends data out by accident, while best-effort filters let it through.
    8. Governance gets simpler: logs and traces hold only tokens, reveal rules decide who sees real values, and deletion requests resolve at the vault. Sign-off from compliance can then depend on controls you own.

    Where Other Techniques Still Fit

    Choosing tokenization as the default doesn't make the other techniques obsolete. Each still has a job:

    • Redaction for values nobody downstream needs, such as card numbers in an unrelated complaint
    • Synthetic data and differential privacy for testing, evaluation, fine-tuning and analytics
    • Format-preserving encryption for structured fields in databases with fixed schemas
    • Self-hosted models for environments that can't reach an outside network at all

    Tokenization also has limits to plan around. It depends on detection, so values in unrecognized formats pass through. Fuzzy matching on names doesn't work once each name is a token, and tasks that need the literal value, such as sorting ID numbers numerically, belong in your own code.

    How to Combine Tokenization With Other Controls

    The strongest setups layer techniques in a deliberate order. Minimization comes first, so fewer values reach the tokenization layer. Tokenization then protects everything that remains, whether it sits in a message, a tool call, a streamed reply or a document headed for an embedding index. Access controls, reveal rules and clean logs govern what happens after the reply. Testing with representative records before launch, and monitoring detections by entity type afterward, confirms the layers work together. Stakes vary by sector, and Enigma's breakdown of AI data security across industries explains how regulated sectors such as healthcare and financial services weigh them.

    How Enigma NoPII Combines PII Protection Techniques for LLM Apps

    For this layer, it doesn't matter which LLM or framework a team chooses. Acting as a reverse proxy ahead of the provider, NoPII relies on Enigma Vault as the underlying infrastructure where each token is kept. NoPII supports nine providers, Anthropic, Gemini and OpenAI among them, and setup means pointing your SDK's base URL at NoPII with two lines of code.

    Here is how the techniques in this article map to what NoPII does:

    TechniqueHow NoPII applies it
    PII detectionA default set of eleven entity types, over two dozen opt-in regional types, checksums where formats support them, 14 secret pattern families, tunable sensitivity and custom terms
    Reversible tokenizationDeterministic tokens with round-trip detokenization, including streamed replies restored in flight
    Context phrase neutralizationLabels such as social security number become neutral wording before the request leaves
    Blocking on failureAny tokenization failure stops the request, by design
    Coverage across the requestMessages, system prompt content and tool calls in both directions, served through Chat Completions, the Responses API and Anthropic Messages, plus embeddings on supported providers
    Access controlsReveal policy, reveal grants with a recorded reason, roles and separate workspaces per tenant
    Logging and retentionLangfuse traces with tokenized content only, an audit log with masked values, configurable token retention and token purge
    EncryptionPer-customer AES-256 keys on vaulted data

    Minimization stays with your team, since NoPII protects whatever you send and sending less is still the best start. Teams can use NoPII as a hosted service or deploy both components inside their own environment. The underlying Enigma Vault platform holds PCI DSS Level 1 and SOC 2 Type II, with a BAA on offer for healthcare workloads.

    A few boundaries apply. NoPII scans text, so images and audio need separate handling. Staff using consumer chatbot sites need endpoint data-loss prevention, and detection isn't yet dependable for names written in Thai or in East Asian scripts.

    The NoPII live demo runs a sample request through tokenization and back.

    To start protecting PII in your own LLM requests, start free with NoPII on a plan that includes one million protected tokens monthly and asks for no credit card.

    AK
    Abhilash Kumar Chief Growth Officer

    Abhilash Kumar is Chief Growth Officer at Enigma Vault, where he leads growth strategy, market positioning, and partnership development. He brings experience across B2B SaaS marketing, product marketing, brand building, and demand generation, with a career spanning technology companies and communications agencies.

    View full profile

    Frequently asked questions

    What is the most effective technique to protect PII in LLM applications?
    When PII has to reach an LLM, reversible tokenization paired with data minimization works best. The provider receives only tokens, the model still reasons correctly and replies return real values, while minimization keeps each request small.
    What is the difference between pseudonymization and tokenization?
    Pseudonymization is the broad category of replacing identifiers with references that need separate information to link back. Tokenization is one method within it, keeping the original values in a secure vault and restoring them under rules.
    Is format-preserving encryption the same as tokenization?
    No. Format-preserving encryption scrambles a value with a key, and anyone holding that key can decrypt it. Tokenization replaces the value with a reference whose original lives only in a vault, so the token itself carries nothing.
    What is the difference between redaction and masking for LLMs?
    Redaction deletes a value and leaves a fixed placeholder, while masking hides part of it or swaps in a fake of the same shape. Both are one-way, so neither lets the real value come back in the model's reply.
    Do self-hosted models remove the need for PII protection?
    They keep prompts away from outside providers, but PII still lands in your own logs, caches and vector stores. Minimization, access controls and clean logs still matter, and many teams prefer hosted models for quality.