International · Spain
Spain DNI & NIE validator.
Check a Spanish DNI (8 digits and a letter) or NIE (X, Y or Z, 7 digits and a letter) against its check letter. Everything runs in your browser.
How it works: divide the number by 23; the remainder (0 to 22) picks the check letter from the table TRWAGMYFPDXBNJZSQVHLCKE. For an NIE, the leading X, Y or Z is first replaced by 0, 1 or 2.
Inputs
Result
Enter a DNI or NIE and press Check.
How the DNI and NIE check letter works
A DNI is eight digits followed by a check letter. An NIE (for foreign nationals) is the letter X, Y or Z, seven digits, and a check letter. The letter is not random: it is derived from the number by a modulo 23 calculation.
| Step | What happens |
|---|---|
| 1 | For an NIE, replace the leading X with 0, Y with 1 or Z with 2 to get an 8-digit number |
| 2 | Divide the 8-digit number by 23 and keep the remainder (0 to 22) |
| 3 | Read the remainder's position in TRWAGMYFPDXBNJZSQVHLCKE (T=0, R=1, W=2 … E=22) |
Worked example: 12345678 divided by 23 leaves 14, the 15th letter is Z, so the DNI is 12345678Z. For the NIE X1234567L, X becomes 0, giving 01234567; the remainder is 19 and the 20th letter is L.
K, L and M numbers are not checked
Agencia Tributaria also issues NIFs beginning K, L and M (Spanish minors under 14, Spaniards living abroad, and foreigners without an NIE). We could not confirm their check-letter algorithm against a primary source, so this tool does not validate them.
Checksum check only, not a registry lookup
A passing result means the letter is consistent with the number. It does not confirm the document exists or belongs to anyone.
Sources
Dirección General de Ordenación del Juego, Cálculo del dígito de control (modulo 23, letter table, X/Y/Z to 0/1/2, worked example 12345678Z). Agencia Tributaria, Composición del NIF, personas físicas (DNI, NIE, K, L, M formats).
Checksum only — not a police or tax registry lookup
This tool checks the modulo 23 check letter entirely in your browser. A checksum-valid result is not proof the number was ever issued. Nothing you type is transmitted, stored, or logged.
Worked example: 12345678Z and X1234567L
| Number | Digits used | Remainder | Letter |
|---|---|---|---|
| 12345678Z | 12345678 | 12345678 mod 23 = 14 | Z (15th letter) |
| X1234567L | 01234567 | 1234567 mod 23 = 19 | L (20th letter) |
| 87654321X | 87654321 | 87654321 mod 23 = 10 | X (11th letter) |
The letter table is TRWAGMYFPDXBNJZSQVHLCKE. Change the DNI letter to T and the tool reports that the number requires Z.
Common mix-ups
-
Often assumedEvery valid Spanish tax number is eight digits followed by a letter.
What the source saysOnly Spaniards with a DNI use their DNI number plus letter. Article 19 of Real Decreto 1065/2007 gives Spaniards living abroad or aged under 14 a nine-character NIF starting with L or K, and article 20 gives foreigners without an NIE one starting with M. [1]
-
Often assumedA foreigner in Spain has a tax number that is separate from their NIE.
What the source saysArticle 20 says that for individuals without Spanish nationality, the NIF is the foreigner identity number (the NIE) assigned to them under Organic Law 4/2000. Only when no NIE exists must they ask the tax agency for a separate M-number. [1]
Checked against these sources on .
Frequently asked questions
Is the check letter random?
No. It is the remainder of the number divided by 23, read in a fixed letter table.
How is an NIE checked?
Replace X, Y or Z with 0, 1 or 2 at the start, then divide the 8-digit result by 23.
Why are K, L and M numbers not validated?
The check-letter algorithm for them could not be confirmed against a primary source, so the tool does not guess.
Can it tell me a DNI is genuine?
No. It cannot query a registry.