How to Identify PII in Data (Step by Step, With AI Help)
Find and classify PII in databases, files and free text. A step-by-step method with pattern checks, an AI prompt, human review and a register.
For Data & Analytics

How do you identify PII in data?
You identify PII by working through your data in layers. List where data lives, read column names and metadata, run pattern checks for formats like emails and ID numbers, use AI to classify what the patterns miss (ambiguous columns and free text), and have a person confirm every result. Then record the decisions in a classification register. AI speeds up the middle steps, but it should see column names and masked samples, not your raw customer records.
TL;DR
- PII is broader than names and SSNs. Combinations like job title, location and birth date can identify a person even when no single field does.
- Start with metadata, not data. Table names, column names and data types settle a large share of classification without anyone opening a record.
- Pattern matching is precise but narrow. Regular expressions (regex) and checksums catch structured values like emails and card numbers. They miss names, addresses and anything typed into a notes field.
- AI is good at the ambiguous middle. Give it column names and a few masked values and it can label what a column probably holds, with a confidence level and a reason.
- Do not paste real personal data into an unapproved AI tool. Finding PII must not create a new exposure.
- A person signs off. Record every decision in a register with an owner, a sensitivity level and a review date.
What counts as PII?
PII (personally identifiable information) is any information that can identify a specific person, alone or combined with other data. Laws use different words. The EU's GDPR says "personal data," California's CCPA says "personal information," and US health rules define their own list of identifiers. The practical test is the same: could someone work out who this record is about?
Split it into three groups.
| Group | Examples | How it behaves |
|---|---|---|
| Direct identifiers | Full name, email, phone, home address, government ID, passport number, employee ID | Identifies a person on its own |
| Indirect identifiers (quasi-identifiers) | Birth date, postal code, job title, gender, device ID, IP address, cookie ID | Identifies a person when combined |
| Sensitive categories | Health, biometrics, genetic data, religion, ethnicity, sexual orientation, union membership, financial account numbers, precise location | Higher harm if exposed, often stricter legal handling |
The middle row is where most teams get caught. A table with only zip_code, birth_date and gender has no names in it, yet it can often point to one individual. Treat combinations as PII until someone has a reason not to.
Step 1: Where does your data actually live?
You cannot classify what you have not found. Before any scanning, build an inventory of every place data is stored. People usually remember the main warehouse and forget the rest.
Check these locations:
- Production databases and the data warehouse
- Analytics extracts, BI dashboards and saved reports
- Shared drives, SharePoint or Google Drive folders, and email attachments
- CRM, HR, ticketing and survey tools
- Log files and error trackers (they often capture emails, IDs and request bodies)
- Backups, test and staging copies (frequently real data, loosely protected)
- Spreadsheets on laptops
For each location, write down the system name, an owner, and how you can get a schema (the list of tables and columns). The owner matters. When a scan flags something, you need a name to ask.
Start with the systems that feed the AI tools you plan to use. That is the point of this exercise: you want to know what is in the data before a model, an agent or a vendor touches it.
Step 2: How do you classify data using column names and metadata?
This is the cheapest step and it is often the most productive. Export the schema only: table name, column name, data type, and any description. No records.
Read it with a few questions in mind:
- Does the name suggest a person? (
customer_name,dob,ssn,home_addr,emp_id) - Is it a free-text field? (
notes,comments,description,message_body). Free text can hold anything. - Is it an identifier that links back to a person? (
user_id,device_id,account_number) - Is it a code you do not recognize? (
fld_17,attr3). Mark these for deeper review.
Legacy systems are full of names like cust_x2. Those need a sample of values, which is step 3 and 4.
Step 3: How do you find PII with pattern matching?
Some PII has a recognizable shape. Pattern checks run fast, cost nothing, and give explainable results. Sample a limited number of rows per column (a few hundred is a common starting point), run the patterns, and measure what share of values match.
| Data type | Check |
|---|---|
Regex for something@domain.tld | |
| Phone | Regex that allows country codes, spaces, dashes and parentheses |
| Government ID (e.g. US SSN) | Format regex such as three digits, two digits, four digits, plus rules for invalid ranges |
| Payment card number | 13 to 19 digits, validated with the Luhn checksum to cut false positives |
| IP address | IPv4 and IPv6 formats |
| Dates that may be birth dates | Date format plus a plausible age range |
| IBAN and similar | Country-specific format plus checksum |
A simple example of an email and SSN-shaped check in Python:
import re
EMAIL = re.compile(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}")
SSN = re.compile(r"\b\d{3}-\d{2}-\d{4}\b")
def match_rate(values, pattern):
values = [v for v in values if v]
if not values:
return 0
hits = sum(1 for v in values if pattern.search(str(v)))
return hits / len(values)
If 90 percent of a column matches the email pattern, you have a strong signal. If 2 percent of a notes column matches, you have a different finding: PII is leaking into free text.
If you do not want to write code, dedicated tools do this for you. Cloud providers offer managed discovery services (for example Amazon Macie for S3, and Google Cloud's Sensitive Data Protection), and Microsoft's open-source Presidio library detects and anonymizes common entity types. Check each vendor's current documentation for what it covers and what it costs.
The weakness of patterns: they cannot recognize a name, a street address, a diagnosis, or a sentence like "call me at my sister's place, she lives on Elm Street." That is where AI helps.
Step 4: How can AI help classify PII?
AI models handle ambiguity well. They can read a column called ref_contact with values like J. Alvarez (Acme) and conclude it holds a person's name and employer. They can read a free-text field and list what kinds of personal details appear in it.
The rule that governs this step: the AI sees the least data needed. Use one of these approaches, in order of preference:
- Schema only. Column names, types and descriptions. No values.
- Masked samples. Replace letters with
Aoraand digits with9before sharing (soJ. AlvarezbecomesA. Aaaaaaaand555-0142becomes999-9999). The shape survives and the content does not. - Synthetic or redacted examples written by someone who knows the data.
- Real samples, only in a tool your company has approved for that data class, or a model running inside your own environment.
Check your company's AI policy before step 4. If you are unsure, use options 1 to 3.
The prompt
Paste this into an approved AI tool, with your schema or masked samples filled in.
You are helping a data governance team classify columns for personal data.
I will give you a table name, its columns, data types, and for each column up to 5 masked sample values (letters replaced with A/a, digits with 9). Do not ask for real values.
For EACH column, return a table with these fields:
- column_name
- likely_content (plain description of what it probably holds)
- pii_category: one of [Direct identifier, Indirect identifier, Sensitive category, Not personal, Unclear]
- sensitive_type: if applicable (health, financial, biometric, location, government ID, other), otherwise "none"
- confidence: High / Medium / Low
- reason: one sentence tied to the column name or sample shape
- question_for_owner: what a human should confirm, if confidence is not High
Then add:
1. A list of column COMBINATIONS in this table that could identify a person even though no single column does.
2. Any free-text columns where personal data might be typed in by users.
3. Your assumptions. If something is ambiguous, say so rather than guessing.
Table: [TABLE NAME]
Business purpose of the table: [ONE SENTENCE]
Columns:
[COLUMN | TYPE | MASKED SAMPLES]
What to check in the answer
- Confidence labels. Treat "Medium" and "Low" as work orders for a human, not as results.
- The combinations list. If it is empty for a table with birth dates and postal codes, push back.
- Invented certainty. If the model states what a cryptic column "is" without a reason tied to the evidence, mark it Unclear.
- Consistency. Run the same table twice. If the answers differ on the same column, a person must decide.
Free-text fields
For notes, support tickets and survey comments, ask for a different output: the types of personal data found (names, phone numbers, health details, account numbers) and an estimate of how common each is, working from a redacted sample. Use the results to decide whether the field needs to be scrubbed, restricted or excluded from any AI use.
Step 5: Who reviews what AI found?
Every AI classification needs a human decision. Split the review by risk:
- High confidence, not sensitive: a data steward spot-checks a sample.
- Medium or Low confidence: the system owner confirms.
- Anything sensitive (health, financial, biometric, government ID, children's data): privacy or legal reviews, and the label is final only after they agree.
Build a short test set to measure the process. Pick 30 to 50 columns you already know the answer for, run them through the same steps, and see how often the pipeline agrees with you. If it misses a known SSN column, find out why before trusting it on columns you do not know.
Step 6: What should a PII classification register look like?
The output of this work is a living document, not a one-time scan. Use a register like this, one row per column or field:
| System | Table / file | Column | Content | PII category | Sensitivity tier | Detected by | Confidence | Owner | Reviewed by | Review date | Notes / handling |
|---|---|---|---|---|---|---|---|---|---|---|---|
| CRM | contacts | Work email | Direct identifier | Confidential | Pattern + AI | High | Sales Ops | J. Doe | 2025-03-01 | Masked in analytics | |
| HR | employees | dob | Date of birth | Direct identifier | Restricted | Column name | High | HR Systems | Privacy | 2025-03-01 | Not for AI use |
| Support | tickets | body | Free text | Unclear (may contain any) | Restricted until scrubbed | AI sample | Medium | Support Ops | Pending | Redact before export |
Keep the tiers simple. Four is plenty:
- Public: safe to share.
- Internal: not personal, not for outsiders.
- Confidential: personal data, access limited by role.
- Restricted: sensitive categories and government or financial identifiers, tightest controls.
Add a column for "approved for AI use" (yes, no, only after masking). That one column answers the question that probably started this project.
Where does AI get PII detection wrong?
Know the failure modes so you can plan for them.
- False positives. A column of product SKUs shaped like phone numbers, or a company name that looks like a person's name. Patterns and models both do this.
- False negatives. Names from cultures the model or tool saw less often, nicknames, misspellings, addresses written in a sentence, and PII embedded in a PDF or image.
- Context blindness. A model reading only a column name cannot tell that
idis a person's national ID in one table and an order number in another. - Re-identification. Each column looks harmless; together they identify someone. Models can flag combinations but cannot judge how unique a combination is in your actual population.
- Inconsistency over time. Models change, prompts drift, and results can differ between runs. Re-test on your known set when anything changes.
- Law is not a model's job. Whether something counts as personal data under a specific regulation, and what you must do about it, is a decision for privacy counsel.
A missed PII field is the costly error. Tune toward over-flagging, then let reviewers clear the false positives.
What about files, PDFs and images?
Structured tables are the easy case. Documents need extra steps:
- Extract the text first (from PDFs, Word files, scans through OCR).
- Run the same pattern checks and AI classification on the text.
- Treat scans, photos and recordings as PII-bearing by default: faces, voices, signatures and ID cards are personal data even with no text.
- Check file metadata. Author names, GPS coordinates and device information are often embedded.
OCR errors lower detection accuracy, so sample and verify by hand.
How often should you repeat this?
Data changes. Rerun discovery when:
- A new system or data source is added
- A schema changes (new columns are the usual culprit)
- A new AI tool or vendor is proposed
- On a schedule, quarterly for high-risk systems and at least yearly for the rest
Add a lightweight rule to your change process: no new column goes into production without a classification entry. That keeps the register from decaying.
Could you build your own PII register tool?
Many teams manage this register in a spreadsheet that goes stale within a month, or buy a governance platform that is more than they need. A middle option is a small internal app: a form where system owners submit tables and columns, a review queue for stewards, role-based access so only privacy staff see Restricted entries, and a dashboard showing what is unreviewed or overdue. With Remy, you can describe that app in plain English and it builds and deploys the full-stack application, with a database, sign-in and roles included, and you own the code in your own git repository. You would still decide the tiers and review rules yourself, and your security team should approve any app that holds sensitive metadata.
Frequently Asked Questions
What is the difference between PII and personal data?
They overlap heavily. "PII" is the common term in US usage, while "personal data" is the GDPR's term and is generally wider, covering things like online identifiers. If you handle data from several regions, use the broader definition for discovery and let legal decide how each law applies.
Is it safe to upload my data to ChatGPT or another AI tool to find PII?
Not unless your company has approved that tool for that class of data. Start with schema-only or masked samples, which keep the real values out of the tool entirely. For real records, use an approved enterprise setup or a model running in your own environment.
Can regex alone find all PII?
No. Regex works well for structured formats like emails, phone numbers and card numbers, especially with checksums. It cannot reliably detect names, addresses, health details or context in free text, so pair it with AI classification and human review.
How many rows should I sample per column?
A few hundred rows per column is a common starting point for pattern checks, and a smaller number of masked examples is enough for AI classification. Increase the sample for columns that are mostly empty or mixed in content. Free-text fields need larger and more varied samples because PII shows up only occasionally.
Who should own PII classification at a company?
The data owner of each system is accountable for their data, with privacy or governance setting the standards and reviewing sensitive cases. Data and analytics teams usually run the discovery work. Legal or privacy counsel decides how the labels map to regulatory obligations.
Useful for
How we source, write, and correct our articles. Editorial standards
Related articles

How to Optimize a Slow SQL Query with AI (Step by Step)

Data Dictionary Template + an AI Prompt to Fill It In

Data Quality Checks: A Checklist and How to Automate Them
