The Basics of k-Anonymity: Making Individuals Harder to Identify
- Swetha Srihari
- Jun 5
- 9 min read
Updated: Jul 20
Part 2 of the Data Privacy Series
If you're new to data privacy concepts, you may find it helpful to start with my previous article, The Privacy Challenge in Machine Learning

Suppose you are given the following information about a person:
Age | Gender | ZIP Code |
29 | Female | 97205 |
There is no name, email address, phone number, or Social Security number associated with the record. At first glance, the data may appear anonymous.
Now imagine trying to determine who this person might be using publicly available information. By narrowing your search to 29-year-old females living in ZIP code 97205, you may be able to reduce the possibilities to a surprisingly small number of individuals. In some cases, identifying the person may be easier than expected.
This example illustrates a basic challenge in data privacy. Simply removing direct identifiers does not always guarantee anonymity. Information that appears harmless on its own can sometimes reveal more than intended when combined with other data sources.
To address this challenge, researchers developed k-Anonymity, a privacy-preserving technique designed to make individuals more difficult to distinguish within a dataset. By ensuring that each record resembles a group of other records, k-Anonymity reduces the risk of re-identification while preserving the data's usefulness for analysis.
In this article, we will explore the fundamentals of k-Anonymity, how it works, and its role in protecting privacy while preserving data value.
What is k-Anonymity?
K-anonymity is a privacy-preserving technique designed to reduce the risk of identifying individuals in a dataset. The central idea is simple:
Each record should be indistinguishable from at least k − 1 other records based on a selected set of attributes.
To understand this concept, imagine a dataset containing information about age, gender, and ZIP code. If a particular combination of these attributes appears only once in the dataset, that record stands out and may be linked to a specific individual. However, if the same combination appears in multiple records, it becomes much more difficult to determine which person a particular record represents.
For example, consider the following records:
Age | Gender | ZIP Code |
24 | Female | 97205 |
26 | Female | 97202 |
29 | Female | 97208 |
22 | Female | 97201 |
28 | Female | 97209 |
Table 1. Original records contain unique combinations of attributes.
Each record is unique because the combination of age, gender, and ZIP code appears only once. An attacker who knows these characteristics about an individual could potentially identify the corresponding record in the dataset.
To reduce this risk, the records can be transformed so that they appear less unique and more similar to one another:
Age Range | Gender | ZIP Code |
20–30 | Female | 972** |
20–30 | Female | 972** |
20–30 | Female | 972** |
20–30 | Female | 972** |
20–30 | Female | 972** |
Table 2. Records after applying generalization to achieve 5-anonymity.
Although these records represent five different individuals, they appear identical with respect to the attributes shown. If an attacker knows that a 29-year-old female living in ZIP code 97205 is included in the dataset, they cannot determine which of the five records belongs to that individual. At best, they can conclude that the person is one of the five members in the group. Because each record is indistinguishable from the other four, the dataset satisfies 5-anonymity (k = 5) for these attributes. Instead of being linked to a single individual, each record becomes part of a larger anonymity group, making re-identification significantly more difficult.
Identifiers, Quasi-Identifiers, and Sensitive Attributes
Before we try to understand how k-Anonymity is used, it is important to understand the different types of information that can appear in a dataset. Not all attributes carry the same privacy risk. Some can directly identify an individual, while others may reveal an identity only when combined with additional information.
In the context of data privacy, attributes are commonly classified into three categories: identifiers, quasi-identifiers, and sensitive attributes.
Attribute Type | Examples | Description |
Identifiers | Name, Social Security Number, Email Address | Directly identify an individual. |
Quasi-Identifiers | Age, Gender, ZIP Code | May identify an individual when combined with other information. |
Sensitive Attributes | Medical Diagnosis, Salary, Political Affiliation | Information that should remain private and protected from disclosure. |
Table 3. Types of attributes commonly found in datasets and their roles in privacy protection.
Identifiers
Identifiers are attributes that can directly identify an individual. Examples include a person's name, Social Security Number, email address, phone number, or driver's license number. Because these attributes uniquely identify a person, they are typically removed or masked before data is shared for research or analysis.
Quasi-Identifiers
Quasi-identifiers are attributes that do not directly identify an individual on their own but may do so when combined with other information.
Common examples include age, gender, ZIP code, date of birth, and occupation. In the example presented earlier, the combination of age, gender, and ZIP code helps narrow down the search to a small group of individuals. K-Anonymity primarily focuses on protecting these types of attributes because they are often responsible for re-identification.
Sensitive Attributes
Sensitive attributes contain information that individuals generally expect to remain private. Examples include medical diagnoses, income, political affiliation, religious beliefs, and financial records. While sensitive attributes may not directly identify a person, their exposure can still lead to privacy violations if linked to an individual's identity.
Understanding the difference between identifiers, quasi-identifiers, and sensitive attributes is essential because k-Anonymity works by modifying quasi-identifiers while preserving as much useful information as possible.
How Does k-Anonymity Work?
K-Anonymity is typically achieved by modifying values in a dataset so that individual records become less unique. The goal is to ensure that each record shares the same combination of identifying characteristics with at least k − 1 other records. Two common techniques used to achieve k-Anonymity are generalization and suppression.
Generalization
Generalization replaces specific values with broader, less detailed categories. This reduces the uniqueness of individual records while preserving the overall usefulness of the data.
For example, instead of storing an exact age such as 29, a dataset may store an age range such as 20–30. Similarly, a ZIP code such as 97205 may be generalized to 972**, hiding the final digits while still retaining approximate geographic information.
In the previous example, the values for age and ZIP code were generalized, hence multiple records appeared identical. As a result, each individual became part of a larger group of anonymity rather than standing out as unique.
Suppression
Suppression removes or masks certain values entirely when they pose a high risk of identifying individuals.
For example, a dataset might replace a ZIP code with a "*" or leave the value blank if generalization alone is not sufficient to achieve the desired
level of anonymity.
Age Range | Gender | ZIP Code |
20–30 | Female | * |
20–30 | Female | * |
20–30 | Female | * |
20–30 | Female | * |
20–30 | Female | * |
Table 4. Example of suppression applied to a quasi-identifier.
While suppression can provide stronger privacy protection, excessive suppression may reduce the quality of data used for analysis.
Combining Generalization and Suppression
In practice, a single technique may not always be sufficient to achieve the desired level of anonymity. Organizations often combine generalization and suppression to ensure that records are no longer unique.
In real datasets, you'll almost always use both together.
Here's an example where age is generalized, ZIP codes are partially masked, and one gender value is fully suppressed:
Age Range | Gender | ZIP Code |
20–30 | Female | 972** |
20–30 | * | 972** |
20–30 | Female | 972** |
20–30 | Female | 972** |
20–30 | Female | 972** |
Table 5. Example of combining generalization and suppression to reduce re-identification risk.
Together, these modifications help ensure that individual records are more difficult to distinguish from one another. While generalization and suppression help achieve k-Anonymity, the level of privacy protection ultimately depends on the value chosen for k.
Choosing the value of k
The value of k determines the size of the anonymity group and directly influences the level of privacy protection provided by k-Anonymity. A larger value of k means that each record is indistinguishable from a greater number of other records, making re-identification more difficult.
For example, in a dataset that satisfies 3-anonymity, each record shares the same identifying characteristics with at least two other records. In contrast, a dataset that satisfies 10-anonymity ensures that each record is part of a group of at least nine similar records.
Generally, larger values of k provide stronger privacy protection because individuals become harder to distinguish from others in the dataset. However, achieving higher values of k often requires more extensive generalization and suppression, which can reduce the quality of the data for analysis.
k value | Privacy Protection | Data Utility |
k = 2 | Low | High |
k = 5 | Moderate | Moderate |
k = 10 | High | Lower |
k = 20 | Very High | Lower |
Table 6. Illustrative relationship between k values, privacy protection, and data utility.
As a result, selecting an appropriate value of k involves balancing privacy and utility. A value that is too small may leave individuals vulnerable to re-identification, while a value that is too large may remove important details needed for meaningful analysis.
The optimal choice depends on factors such as the sensitivity of the data, the risk of disclosure, and the intended use of the dataset. At this point, it may seem that increasing the value of k is enough to protect privacy. However, privacy is not only about hiding an individual's identity. It is also about preventing sensitive information from being inferred. Even when a dataset satisfies k-Anonymity, certain patterns within the data—or information obtained from external sources—may still reveal private details about individuals.
Limitations of k-Anonymity
While k-Anonymity reduces the risk of identifying individuals, it does not provide complete privacy. It hides a person’s identity by making each record look similar to at least k − 1 others. However, sensitive information can still be revealed in some situations. Two common examples are homogeneity attacks and background knowledge attacks.
Homogeneity Attack
When everyone in an anonymity group shares the same sensitive value, homogeneity attacks can easily occur. The group hides which record is yours — but it doesn't matter, because every record says the same thing.
Age Range | Gender | ZIP Code | Disease |
20–30 | Female | 972** | HIV |
20–30 | Female | 972** | HIV |
20–30 | Female | 972** | HIV |
20–30 | Female | 972** | HIV |
20–30 | Female | 972** | HIV |
Table 7. Example of a homogeneity attack.
If an attacker knows you're in this group, they immediately know your diagnosis. k-Anonymity did its job — you can't be identified — but the sensitive information leaked anyway. That's a problem.
Background Knowledge Attack
This one is subtler. Even when a group contains diverse sensitive values, an attacker who knows something about you from outside the dataset might be able to narrow it down.
Age Range | Gender | ZIP Code | Disease |
20–30 | Female | 972** | HIV |
20–30 | Female | 972** | HIV |
20–30 | Female | 972** | Flu |
20–30 | Female | 972** | Cancer |
20–30 | Female | 972** | Flu |
Table 8. Example of a background knowledge attack.
Suppose an attacker knows — from a news article, a social media post, a hospital visit logged elsewhere — that the person they're looking for recently underwent cancer treatment. Suddenly, the "Cancer" record in that group is the obvious match. The k-Anonymity held up technically. The privacy didn't.
The key difference between these two attacks is that homogeneity is a problem with the data itself; background knowledge is a problem with the world outside the data. k-Anonymity can't fully protect against either one, which is why more advanced techniques like l-diversity and differential privacy were developed to address these gaps.
Real-World Applications of k-Anonymity
Despite its limitations, k-Anonymity is still genuinely useful — especially as a first layer of protection or in contexts where the privacy stakes are moderate.
Healthcare: Patient datasets shared for research or public health analysis are often anonymized using k-Anonymity before release. It's not perfect, but it's better than publishing raw records.
Government and Census Data: Demographic data published for policymaking and research needs to be detailed enough to be useful but not so specific that individuals can be identified. k-Anonymity helps strike that balance.
Academic Research: Many research datasets contain personal information. Applying k-Anonymity lets organizations share data with researchers while reducing exposure for study participants.
Business Analytics: Before sharing customer data internally or with partners, companies often apply anonymization. k-Anonymity is a common starting point.
Conclusion
k-Anonymity is one of those ideas that's elegant in its simplicity and genuinely useful in practice — but it's easy to over-rely on it. It does one thing well: it makes individuals harder to pick out of a crowd. What it can't do is guarantee that sensitive information stays hidden once you've found the crowd.
That's not a reason to dismiss it. It's a reason to understand it clearly and use it as part of a broader privacy strategy rather than a complete solution on its own. The techniques that came after it — l-diversity, t-closeness, differential privacy — were all built to address the gaps k-Anonymity left open. Understanding those gaps is, I'd argue, the most important takeaway from this article.
References
Sweeney, L. (2002). k-Anonymity: A Model for Protecting Privacy. International Journal of Uncertainty, Fuzziness and Knowledge-Based Systems, 10(5), 557–570.
Samarati, P., & Sweeney, L. (1998). Protecting Privacy When Disclosing Information: k-Anonymity and Its Enforcement Through Generalization and Suppression. Proceedings of the IEEE Symposium on Research in Security and Privacy.
Machanavajjhala, A., Gehrke, J., Kifer, D., & Venkitasubramaniam, M. (2007). l-Diversity: Privacy Beyond k-Anonymity. ACM Transactions on Knowledge Discovery from Data, 1(1).
Dwork, C. (2006). Differential Privacy. Proceedings of the 33rd International Conference on Automata, Languages and Programming (ICALP).
AI Assistance Disclosure
The author wrote the content of this article. ChatGPT (OpenAI) was used solely to assist with editing, improving clarity, grammar, readability, and overall organization. All ideas, analysis, and conclusions are the author's own.


