DNI/NIE Calculator

Calculate the check letter for a Spanish DNI or NIE, or paste a full document to confirm its letter is correct. Switch between the two modes with the buttons below.

8 digits for a DNI, or X, Y, or Z followed by 7 digits for a NIE.

How It Works

The final letter on a Spanish DNI or NIE is not chosen freely. It is calculated from the digits, which is why a small typo in the number almost always produces the wrong letter and gives the mistake away.

For a DNI, take the eight digits as a whole number and divide by 23. The remainder, a value from 0 to 22, is a position in the fixed list of letters T, R, W, A, G, M, Y, F, P, D, X, B, N, J, Z, S, Q, V, H, L, C, K, E. The letter at that position is the check letter. A NIE works the same way, except its leading letter is first turned into a digit: X into 0, Y into 1, and Z into 2.

Worked Example

Take the sample number 12345678, which is an example and not a real document. Dividing 12345678 by 23 leaves a remainder of 14. Counting from zero, position 14 in the list above is the letter Z, so the full DNI would be 12345678Z. For a NIE such as X1234567, the X becomes 0, giving 01234567, which divided by 23 leaves a remainder of 19, and position 19 is the letter L, giving X1234567L.

When You Would Use This

This is handy when you have to write a DNI or NIE onto a form and want to be sure it is right, or when a document is worn and you cannot read the last character clearly. Someone renting a flat, opening an account, signing a contract, or filling in an official application can confirm in seconds that the number and its letter agree, and avoid a form that gets bounced back for a single wrong character.

Frequently Asked Questions

What is the difference between a DNI and a NIE?

A DNI is the national ID number for Spanish citizens: eight digits and a letter. A NIE is the identity number for foreigners in Spain: a leading letter X, Y, or Z, then seven digits, then a check letter. Both use the same method to work out that final letter.

How is the check letter chosen?

The number is divided by 23, and the remainder points to one letter in a fixed list of 23. There are 23 letters because the alphabet used here leaves out I, O, U, and N with a tilde to avoid mixing them up with digits or with each other.

Why does a NIE letter get replaced with a number first?

A NIE starts with a letter, but the calculation needs digits. So X becomes 0, Y becomes 1, and Z becomes 2. After that swap the NIE is treated as an eight-digit number and follows exactly the same steps as a DNI.

Does a correct letter mean the DNI is real?

No. The letter only proves the number and letter are consistent with each other. It does not mean the document was ever issued or that it belongs to a particular person. It is a format check, not a lookup.

Can I use this if I forgot the letter on my own document?

Yes. Switch to the calculate mode, type the eight digits of your DNI or the letter and seven digits of your NIE, and the tool returns the letter that belongs with it.