By Saul Martin · · 4 min read
When OpenAnonymizer redacts a text, each value it finds becomes a placeholder such as <EMAIL_1> or <ES_DNI_1>. The text stays readable and the value is gone from it. It is tempting to call the result anonymous. Under the GDPR it usually is not, and the difference decides how you may store, share and reuse it.
This post explains what the placeholders are, why the output counts as pseudonymised, and what follows from that. It is not legal advice: for your own case, ask your data protection officer or a lawyer.
Numbered placeholders and the mapping
By default placeholders are numbered per type, in the order values appear. The first email is <EMAIL_1>, a different email is <EMAIL_2>, and the first email again is <EMAIL_1> again. Numbering restarts with every call, so the tag says nothing about the value behind it.
With the redacted text you also get the mapping: which placeholder stands for which value. That is what lets you put real values back into a reply, or check what was removed. The library returns the mapping to you and never stores it. Where it goes next is your decision.
"placeholders": {
"<ES_DNI_1>": { "type": "ES_DNI", "value": "48213067F" }
}Keyed placeholders
Because numbered tags restart in every call, the same person gets unrelated tags in two files. When records must line up across calls, give the redactor a private key. Each placeholder then becomes <TYPE_hex>: hex digits of an HMAC-SHA256 of the type and value under your key.
from openanonymizer import Redactor
r = Redactor(placeholder_key=b"replace with a long random secret")
r.redact_text("Mi DNI es 53817046J")[0] # 'Mi DNI es <ES_DNI_ecdac08e393a>'With the same key, the same value gets the same tag in every call, file and machine. That is the point: redacted records from different systems still join.
It has a cost. Whoever holds the key can re-identify values by hashing guesses: compute the tag for a candidate value and compare. Where a value has few possibilities, such as a national ID with a check digit, a phone number in one country or a date of birth, trying every candidate is quick on a laptop.
- Keep the key with your system's other secrets, never next to the output.
- Use one key per purpose. Two outputs made with the same key can be joined on their tags; outputs that must not be linkable need different keys.
- Rotating the key is the only way to break the link between old and new output.
Why the output is still personal data
The GDPR (Article 4(5)) defines pseudonymisation as processing personal data so that it can no longer be attributed to a specific person without additional information, provided that information is kept separately and protected. Placeholders fit that definition: the mapping, or the key, is the additional information.
Recital 26 adds that pseudonymised data which could be attributed to a person with additional information should be considered information on an identifiable person. It is still personal data, and the GDPR still applies to it. Only data that no longer relates to an identifiable person, considering all the means reasonably likely to be used, is anonymous.
Redacted text has a second reason to stay personal: what the redaction leaves in. In Fast, the default mode, names in running prose stay as written, because it finds names only where the text labels them; Full’s model also finds them in running text, but no model catches every name. Quasi-identifiers such as age, job or city, and special categories such as health, are off by default. A phrase like "the only cardiologist in the village" can point to one person with no ID in sight.
So treat redacted output as personal data, with a legal basis, access controls and a retention period, like the original.
What it means for data minimisation
One of the GDPR’s principles, data minimisation (Article 5(1)(c)), asks that personal data be adequate, relevant and limited to what is necessary for the purpose. Pseudonymisation does not take you outside that rule, but the GDPR names it as a way to meet it: its rules on data protection by design (Article 25(1)) give pseudonymisation as an example of a measure that implements principles such as data minimisation, and its rules on security (Article 32(1)(a)) list it among the measures to consider.
In practice, that comes down to a few choices:
- Keep the mapping only if you need to restore values. If you only need the redacted text, for analytics or training, discard it.
- If you keep it, store it apart from the output, with tighter access.
- Prefer numbered placeholders when records do not need to join across calls. Use a key only when they do, and scope it to that purpose.
- For datasets, turn on quasi-identifiers and special categories where your data has labelled fields for them, and check free text for names in prose.
- Ask whether you need the field at all. Not keeping it is still the simplest minimisation.
Placeholders reduce what each system sees. They do not end your responsibility for the data.
Our GDPR page covers how this applies to OpenAnonymizer in more detail. The library runs in your own process, so neither the text nor the mapping is sent to us; its terms are on the licence page.