CheckIDs Try the redaction API

馃嚜馃嚫 DNI / NIE validator

Also in: Espa帽ol

The Spanish DNI (Documento Nacional de Identidad) is 8 digits followed by a check letter. The NIE (N煤mero de Identidad de Extranjero) for foreigners starts with X, Y or Z instead.

Runs entirely in your browser; nothing you type is sent anywhere.

Generate test DNI / NIE numbers

Fictional numbers with correct check digits, for testing software. They may by chance match a real person's number, so never use them to identify or impersonate anyone.

Click a number to copy it.

How a DNI / NIE is structured

How the check works

Using the published example 12345678Z:

Divide the number by 23 and look up the remainder: 12345678 mod 23 = 14, and position 14 in TRWAGMYFPDXBNJZSQVHLCKE (counting from 0) is Z. For a NIE, first replace X, Y or Z with 0, 1 or 2.

A passing check only means the number is well-formed; it doesn't prove the number was issued to anyone.

Finding DNI / NIE numbers in text? The EU PII Redaction API finds and replaces national ID numbers from 21 EU/EEA countries, plus names, IBANs, emails and phones, in free text: for example before sending customer messages to an LLM. Free plan available; Python package and MCP server on GitHub.

Frequently asked questions

Which letters are never used?

I, 脩, O and U are left out of the check letters to avoid confusion with similar-looking characters.

Is the DNI number the same as the NIF?

For Spanish citizens, yes: the NIF (tax number) is the DNI number with its letter.

Other validators