Letra DNI calculator: check a DNI or NIE letter (Spain)
Work out the letra of a DNI or NIE in Spain (number modulo 23) or check one you typed: the tool shows the expected letter when it is wrong.
How the DNI and NIE letter is calculated in Spain
In Spain, the letter of a DNI is the remainder of the number divided by 23, turned into a letter with the table TRWAGMYFPDXBNJZSQVHLCKE. For a NIE, X is first replaced by 0, Y by 1 and Z by 2. Example: 12345678 leaves a remainder of 14, so the letter is Z.
The rule
The DNI number (8 digits) is divided by 23. The remainder, from 0 to 22, points to a letter in the official table: 0 = T, 1 = R, 2 = W, 3 = A … 14 = Z … 22 = E. The letters I, O, U and Ñ are never used so they cannot be confused with 1, 0, V and N. A foreigner's NIE (X, Y or Z plus 7 digits) follows the same calculation once the leading letter is replaced: X = 0, Y = 1, Z = 2.
Two examples
- DNI 12345678: 12,345,678 = 23 × 536,768 + 14. Remainder 14 gives Z, so 12345678Z.
- NIE X1234567: X becomes 0, and 01234567 = 23 × 53,676 + 19. Remainder 19 gives L, so X1234567L.
What the tool does
It accepts input with or without the letter, spaces, dots or dashes, pads a short DNI with leading zeros and shows the normalised form. When you type a letter it tells you whether it is right and, if not, which letter was expected. It also says why an entry is rejected.
Limits
A correct letter only shows that the number is consistent; it does not prove the document exists. Company tax numbers follow a different rule and are not covered.
Sources and dates: Spanish Ministry of the Interior, “Cálculo del dígito de control del NIF/NIE”, which gives the 23-letter table and the X/Y/Z conversion; the number and its check letter are set by article 12 of Real Decreto 255/2025 of 1 April (checked on 15/10/2026).
Frequently Asked Questions
How do I find the letter of a Spanish DNI?
Divide the 8-digit number by 23 and keep the remainder. That remainder (0 to 22) maps to a letter of the sequence TRWAGMYFPDXBNJZSQVHLCKE: 0 = T, 14 = Z, 22 = E. For 12345678 the remainder is 14, so the letter is Z.
How is the letter of a NIE starting with X, Y or Z calculated?
Replace X with 0, Y with 1 and Z with 2, then apply the same modulo 23 calculation to the resulting number. X1234567 becomes 01234567, whose remainder is 19, so the letter is L.
Does a correct letter mean the DNI exists?
No. The letter only catches typing errors: about 1 invented number in 23 gets a correct letter by chance. Only the Spanish authorities can confirm that a DNI or NIE has been issued.
Is this tool really free?
Yes, all tools on Kristools are 100% free and accessible without registration.
Is my data protected?
Yes. All processing is performed directly and securely inside your browser. No personal data is sent to our servers.