National ID numbers in documents: the rules country by country
Article 87 GDPR lets each EU country add rules for national ID numbers. See the rules in 8 countries and how to mask these numbers in documents.
A national ID number in a document follows more than the GDPR. Article 87 GDPR lets each EU country set its own conditions, and several have strict rules. The safe default: keep the number only where a law requires or allows it, and mask the whole number everywhere else.
This guide covers eight countries as of October 2026. It is general information, not legal advice. For a real case, ask your data protection officer (DPO) or a lawyer.
What does Article 87 GDPR say?
Article 87 has two sentences. First, member states “may further determine the specific conditions” for processing a national identification number. Second, where they do, the number may be used “only under appropriate safeguards” for the person’s rights and freedoms.

In plain words, the GDPR sets the floor and each country adds its own conditions. The article also covers “any other identifier of general application”, meaning a number that many services use.
What are the rules in each country?
| Country and number | Where it shows up | National rule | Masking tip |
|---|---|---|---|
| France: NIR (numéro d’inscription au répertoire, the social security number) | Payroll, health insurance | Art. 30 of the loi Informatique et Libertés: a Conseil d’État decree sets who may use the NIR and why. That is decree n° 2019-341 of 19 April 2019. The CNIL, France’s data protection authority, says to check your use is listed there. | Mask it in HR files outside payroll: the CNIL finds it unjustified there. |
| Belgium: numéro de Registre national or Rijksregisternummer (national register number) | eID card copies | Law of 8 August 1983, Art. 8: use for tasks of general interest needs the Interior Minister’s authorisation, unless a law, decree or ordinance explicitly provides for it. Art. 8 lists other exceptions. | Mask it unless the recipient has that legal basis. |
| Netherlands: BSN (burgerservicenummer, citizen service number) | ID copies, health and school records | UAVG (Dutch GDPR Implementation Act), Art. 46: a number prescribed by law is used only to carry out that law or for purposes set by law. | Mask it for anyone without a legal basis. |
| Germany: steuerliche Identifikationsnummer (tax ID) | Tax forms | § 139b(2) AO: without consent, other bodies may process it only for exchanges with the tax authorities. A law may also explicitly allow or order it. | Keep it only in the copy for the tax office. |
| Germany: Versicherungsnummer (social insurance number) | Payroll, social insurance notices | § 18f(3) SGB IV: employers and third parties may process it only for legally required notifications, contributions or benefits. | Mask it outside payroll and social insurance. |
| Austria: Sozialversicherungsnummer (SVNR, social insurance number) | Social insurance documents | § 460d ASVG allows its use in data processing for social insurance and the AMS (public employment service). It says nothing about other uses. | Mask it outside social insurance files. |
| Spain: DNI and NIE (ID numbers of Spanish nationals and of foreigners) | ID copies, official publications | LOPDGDD, additional provision 7: a published administrative act gives the name plus four digits, never the name with the full number. | Use the fixed digits below, or mask it all. |
| Luxembourg: numéro d’identification (national identification number, the matricule) | ID card, personnel files, prescriptions | Law of 19 June 2013, Art. 2: lists the documents that may carry it, such as personnel records. | Mask it outside those uses. |
| Italy: codice fiscale (tax code) | Tessera sanitaria (health card), public notices | Guidelines n. 243 of 15 May 2014 from the Garante (Italy’s data protection authority), issued before the GDPR. They are guidance, not law: public bodies should not publish it on their transparency web pages. | Mask it before anything goes online. |
Spain: which digits may be shown?
Spain has a precise rule on partial display. Additional provision 7 of the LOPDGDD, Spain’s 2018 data protection law, applies when a public administration publishes an act. The act names the person plus four random digits of the ID number, never the name with the full number.
In March 2019, Spain’s data protection authority (AEPD) and three regional authorities published a provisional criterion. For a DNI written 12345678X, show the fourth to seventh digits: ***4567**. For an NIE written L1234567X, show ****4567*.
Why are national numbers so risky in a leaked document?
First, they last. Germany’s tax ID is a uniform, permanent identifier under § 139a AO. The Austrian SVNR usually stays the same for life, says a 2008 parliamentary answer. Second, they link files, as the Dutch data protection authority (AP) warns about the BSN. Third, many hide personal details in their digits.
- France: the NIR shows sex, year and month of birth, and place of birth.
- Belgium: the birth date, then a sequence number that is even for women and odd for men.
- Germany: the social insurance number holds the birth date, the birth name’s initial and a serial that may show sex.
- Austria and Luxembourg: the SVNR usually ends with the birth date, the Luxembourg number starts with it.
- The German tax ID is different: by law, it may not be derived from other data about the person.
So masking the name protects little if the number stays. A Belgian number next to a job title reveals age and sex at a glance.
Where do national numbers hide in a document?
- Headers and footers, repeated on every page of a payroll or insurance template.
- Payslip boxes and the filled fields of a PDF form.
- Scanned ID cards: Luxembourg’s 2013 law puts the number on the identity card.
- Barcodes and QR codes, which can encode the number. You cannot read them, but a phone can.
- File names and email subjects, which leak the number before anyone opens the file.
ID copies have their own rules. In Germany, § 20 PAuswG allows a copy only by the holder or with the holder’s consent. The copy must be clearly marked as a copy, and people other than the holder may not pass it on to third parties. The Dutch AP tells people to make the BSN unreadable on a copy if the organisation may not use it.
Take Erika Mustermann’s payslip, sent to an outside auditor. Her tax ID sits in the header and her social insurance number in a box. The auditor checks totals, not identities. So both numbers go, everywhere they appear.
ONYRI Sanitize looks for these numbers country by country. It verifies the check key of the Belgian national number, the German tax ID and social insurance number, and the Austrian SVNR. The Dutch BSN needs its label or a valid check. It spots the NIR, DNI, NIE, codice fiscale and Luxembourg number by format. Limit: a number that fails its check, for example after a misread scan, can stay visible. Read the “Detected data” list.
How do you mask a national number properly?
- Check whether a law requires or allows the number for this recipient, like the tax office. If not, it goes.
- Mask the whole number, unless a rule like Spain’s sets the visible digits.
- Find every occurrence: headers, footers, form fields, appendices and scans.
- Draw a box over barcodes, QR codes and ID card photos.
- Export a flattened file, then try to copy the masked text. Nothing should come out.
- Rename the file if its name reveals the number or the person. Keep the original safe.
Frequently asked questions
Can I just hide the first digits of a national number?
Usually not. The visible digits can be completed from other copies. Spain is the exception for published administrative acts, with fixed positions. Outside such a rule, mask the whole number.
May my employer put my social security number in my HR file?
It depends on the country. In France, the CNIL accepts the NIR for payroll but finds it unjustified in other HR files. In Germany, § 18g SGB IV voids contract clauses demanding the number for uses § 18f does not allow. Elsewhere, ask your DPO.
Is a document anonymous once the national number is masked?
No. Names, addresses, birth dates and rare details can still point to a person. Masking the number removes the strongest link, not every link.
Which rule applies when a document crosses a border?
Article 87 leaves the conditions to each member state, so there is no single answer. It depends on who processes the document, and where. Ask your DPO or a lawyer.
Sources & references
- Art. 87 GDPR – Processing of the national identification numbergdpr-info.eu
- Le décret « cadre NIR » en questionsCNIL
- Loi n° 78-17 du 6 janvier 1978 (Informatique et Libertés), art. 30, consolidated textCNIL
- Peut-on utiliser le numéro de sécurité sociale (NIR) pour la gestion des ressources humaines ?CNIL
- Numéro de Sécurité sociale : compositionService-Public (DILA)
- Le numéro de sécurité sociale (NIR)Assurance Maladie (ameli.fr)
- Loi du 8 août 1983 organisant un Registre national des personnes physiquesJustel, SPF Justice (Belgium)
- Arrêté royal du 3 avril 1984 relatif à la composition du numéro d’identificationJustel, SPF Justice (Belgium)
- Uitvoeringswet Algemene verordening gegevensbescherming, Art. 46wetten.overheid.nl (Netherlands)
- Burgerservicenummer (BSN)Autoriteit Persoonsgegevens
- § 139a AO (Abgabenordnung, German tax code) – IdentifikationsmerkmalFederal Ministry of Justice (gesetze-im-internet.de)
- § 139b AO (Abgabenordnung, German tax code) – IdentifikationsnummerFederal Ministry of Justice (gesetze-im-internet.de)
- § 18f SGB IV (Sozialgesetzbuch, Social Code Book IV) – Zulässigkeit der VerarbeitungFederal Ministry of Justice (gesetze-im-internet.de)
- § 18g SGB IV (Sozialgesetzbuch, Social Code Book IV) – Angabe der VersicherungsnummerFederal Ministry of Justice (gesetze-im-internet.de)
- § 147 SGB VI (Sozialgesetzbuch, Social Code Book VI) – VersicherungsnummerFederal Ministry of Justice (gesetze-im-internet.de)
- § 20 PAuswG (Personalausweisgesetz, ID Card Act) – Verwendung durch öffentliche und nichtöffentliche StellenFederal Ministry of Justice (gesetze-im-internet.de)
- § 460d ASVG (Allgemeines Sozialversicherungsgesetz, General Social Insurance Act)RIS, Federal Chancellery (Austria)
- Anfragebeantwortung 4690/AB XXIII. GP on the social insurance numberAustrian Parliament
- Ley Orgánica 3/2018 (LOPDGDD), consolidated textBoletín Oficial del Estado (BOE)
- Orientación para la aplicación provisional de la disposición adicional séptima de la LOPDGDDAEPD
- Loi du 19 juin 2013 relative à l’identification des personnes physiques (Mémorial A n° 107)Legilux (Luxembourg)
- Structure du numéro d’identité (matricule)Centre commun de la sécurité sociale (Luxembourg)
- Il Codice Fiscale – Che cos’è e come si ottieneAgenzia delle Entrate
- Linee guida per finalità di pubblicità e trasparenza sul web (n. 243, 15 May 2014)Garante per la protezione dei dati personali