How to Anonymise a Dataset: Masking, Hashing and k-Anonymity
Anonymising CSV data: why removing names is not enough, masking, hashing, pseudonyms, generalisation and checking k-anonymity before sharing.

How to Anonymise a Dataset: Masking, Hashing and k-Anonymity
Teams constantly need to share data: with a contractor building a dashboard, a researcher, a test environment or the public. The usual first step, deleting the name column, is rarely enough. People can often be identified from the combination of a few ordinary fields. The CSV Data Anonymizer helps you do the job properly in your browser. Here is the thinking behind it.
Why removing names is not enough
Latanya Sweeney showed in 2000 that date of birth, sex and five-digit ZIP code alone uniquely identified about 87 % of the US population. Fields like these are quasi-identifiers: harmless alone, identifying together, especially when someone can look them up in another dataset such as a voter list or social media.
Direct identifiers: remove, mask, hash or replace
Names, emails, phone numbers, account numbers and ID numbers identify people directly. Options:
- Remove the column if the recipient does not need it.
- Mask it, keeping only the last few characters for reference.
- Hash it with a secret salt, so the same person gets the same code and records can still be joined across files, but the original cannot be read.
- Replace it with a consistent fake value, such as a realistic made-up name, which keeps the data easy to read for testers.
Beware hashing without a salt: phone numbers or ID numbers have a limited range, and an attacker can hash every possible value and look yours up.
Quasi-identifiers: generalise
For fields like age, dates and postcodes, generalisation keeps usefulness while reducing precision:
- Ages into bands: 37 becomes 30-39.
- Dates to year or year-month.
- Postcodes to their first few characters.
- Salaries into ranges, or with small random noise.
Measuring with k-anonymity
A dataset is k-anonymous if every combination of quasi-identifier values appears at least k times. With k = 5, anyone trying to single out a person finds at least five matching rows. The tool computes k after your transformations, shows how many rows sit in groups smaller than your target and can remove those rows.
To raise k, generalise more: wider age bands, shorter postcodes, fewer date details. Each step trades detail for privacy; choose the level the recipient actually needs.
Pseudonymous is not anonymous
Under the GDPR, data that can be re-identified with additional information, such as the salt used for hashing, is pseudonymised and still counts as personal data, with the usual rules applying. Data is anonymous only when no one can reasonably identify people from it. Keep salts secret and separate, and for public release prefer aggregation and strong generalisation.
Watch the free text
Comment fields, notes and descriptions often contain names, phone numbers and addresses. Remove or redact them unless they are essential, and check a sample by hand.
Utility versus privacy
Every transformation removes information. Analysts may need exact dates for time trends or precise amounts for totals. Talk to the people who will use the data before choosing methods: often year-month dates and 5-year age bands are perfectly adequate, and keeping exact values only where they are truly needed avoids weakening the whole file.
A workable routine
- Decide what the recipient really needs.
- Remove columns they do not need.
- Hash, mask or fake the direct identifiers.
- Mark quasi-identifiers and generalise until k meets your target.
- Check free text and a sample of rows.
- Record what you did and keep the salt safe.
Summary
Good anonymisation removes direct identifiers and limits the power of quasi-identifiers, then checks the result. The CSV anonymizer runs everything in your browser, so the original data never leaves your computer while you prepare a safer copy.



