Spanish ID (DNI) letter calculator
Enter the 8 digits of a Spanish DNI (or an NIE starting with X, Y or Z) to get its check letter. If you also type the letter, we will verify that it is correct.
How is the DNI letter calculated?
The letter of the Spanish DNI (Documento Nacional de Identidad, the national ID card) is a check character used to detect typing errors in the number. It is obtained by dividing the 8 digits by 23 and taking the remainder (a value between 0 and 22); each remainder maps to a letter according to this table:
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
For example, for the number 12345678: 12345678 ÷ 23 leaves a remainder of 14, which corresponds to the letter Z, so the full DNI is 12345678Z. The letters I, Ñ, O and U are not used to avoid confusion with the digits 1 and 0 and with other letters.
Are DNI and NIF the same thing?
For Spanish nationals, yes: the NIF (Número de Identificación Fiscal, the tax ID number) is the DNI number followed by its letter. That is why the DNI letter is also known as the NIF letter.
The NIE letter
The NIE (Número de Identidad de Extranjero, the foreigner ID number) starts with a letter (X, Y or Z) followed by 7 digits and a check letter. To calculate it, the initial letter is replaced by a digit (X=0, Y=1, Z=2), the same remainder-of-23 calculation is applied and the same letter table is used. This tool does it automatically.