The DNI/NIE Validator checks whether a Spanish identity document has the correct control letter. It accepts two formats, the DNI (8 numbers and a letter) and the NIE (X, Y or Z, 7 numbers and a letter), and detects on its own which one you pasted. The calculation runs in the browser.
Notice: the tool validates only the letter. It does not query the Ministerio del Interior or the Policía Nacional, so it does not say whether the document exists, is in force or belongs to anyone.
What the DNI and the NIE are, and which country
The DNI (Documento Nacional de Identidad) is the identity document of Spanish citizens. The NIE (Número de Identidad de Extranjero) is the number given to foreigners in Spain. This tool deals only with Spain: the "DNI" of other countries, such as Argentina and Peru, has its own format, without the Spanish control letter, and is not validated here.
The letter is a calculation, not a lottery
For the DNI, you divide the 8-digit number by 23 and use the remainder as a position in the sequence TRWAGMYFPDXBNJZSQVHLCKE, starting at zero:
Remainder and letter: 0 T, 1 R, 2 W, 3 A, 4 G, 5 M, 6 Y, 7 F, 8 P, 9 D, 10 X, 11 B, 12 N, 13 J, 14 Z, 15 S, 16 Q, 17 V, 18 H, 19 L, 20 C, 21 K, 22 E.
This is the table published by the Ministerio del Interior. Note that I, O and U never appear, nor does Ñ. A DNI ending in one of those letters is invalid by construction.
Worked examples
- DNI 12345678. 12,345,678 ÷ 23 leaves remainder 14, and the letter at position 14 is Z. The correct document is
12345678Z. - NIE X1234567. First, the X becomes 0, which gives the number 01234567, or 1,234,567. Dividing by 23, the remainder is 19 and the letter is L:
X1234567L. - NIE Y1234567. The Y becomes 1, giving 11,234,567. The remainder is 10 and the letter is X:
Y1234567X.
What the tool does not check
- Whether the number was issued. Any 8-digit sequence has a correct letter, and most were never assigned.
- CIF and other formats. The tax number of companies (CIF) uses another calculation and is not accepted. Only DNI and NIE with X, Y or Z go in.
- Document validity. An expired or cancelled document is still valid in the math.
Common invalid entries
- Old 7-digit DNI. Someone with a short number must pad it with a zero on the left, so
1234567Lbecomes01234567L. Without that, the tool rejects it for length. - Wrong or forgotten final letter.
- I, O or U in place of the control letter.
- A NIE starting with a letter other than X, Y or Z.
How to use
Paste the document, with or without a hyphen, and click Validate. To create fictitious documents for testing, use the Generator tab or the DNI/NIE Generator. Another identification document with a check digit is in the RUT Validator, from Chile.