Skip to content

Spanish DNI and NIE: anonymize them before ChatGPT or sharing

The Spanish DNI and NIE (Spain) are the national identity numbers of Spanish citizens (DNI) and of foreign residents (NIE). They are also the tax number (NIF) of individuals. They turn up in documents people want to share or give to an AI assistant, and they should never go out as they are.

DNI: 8 digits and a control letter (12345678Z). NIE: X, Y or Z, 7 digits and a control letter (X1234567L). The letter is the number modulo 23.

Nothing by itself, but it is the key to a person in every Spanish register: tax, health, banks, employers, notaries.

Contracts, invoices, payslips, employment contracts, medical and insurance forms, notarial deeds, court documents.

Piixie has a dedicated rule for it, in every model including Lite: it matches the format and checks the control digits, so random numbers of the same length aren’t flagged and real ones aren’t missed. The local LLM also reads the context around it.

With Synthesize, a fake of the same kind with correct check digits, consistent everywhere the same number appears. With Redact, a black box or [REDACTED]; with Replace, a placeholder such as [ID_1].

All of it happens on your computer: the document is never uploaded to find the numbers. See why a local LLM.