Everyday calculators

Spanish DNI/NIE letter calculator

Get the check letter of a Spanish ID (DNI) or foreigner ID (NIE), or verify whether a full number is valid.

For example 12345678, X1234567 or 12345678Z. The number stays in your browser and is never added to the share link.

Spanish DNI/NIE letter calculator: what it is and how it works

The Spanish national ID (DNI) has eight digits and a check letter used to detect typing errors. The letter is found by dividing the number by 23 and taking the remainder, from 0 to 22. Each remainder corresponds to a letter in the sequence TRWAGMYFPDXBNJZSQVHLCKE: 0 is T, 1 is R, and so on. The letters I, Ñ, O and U are not used to avoid confusion.

The NIE, the identification number for foreign residents, starts with X, Y or Z, which are replaced by 0, 1 and 2 respectively before applying the same calculation. It is handy for checking forms or spotting typos; the calculation runs in your browser and nothing is stored.

How to use it

  1. Enter the DNI number (8 digits) or NIE (letter plus 7 digits).
  2. If you include the letter, the calculator checks whether it is correct.
  3. See the check letter and the full document number.
FormulaLetter = TRWAGMYFPDXBNJZSQVHLCKE[number mod 23] · NIE: X = 0, Y = 1, Z = 2

Worked example

For 12345678, the remainder of dividing by 23 is 14, which is the letter Z: 12345678Z. For NIE X1234567, the calculation uses 01234567 and the letter is L.

Frequently asked questions

How is the DNI letter calculated?

Divide the number by 23; the remainder (0–22) gives the position of the letter in the sequence TRWAGMYFPDXBNJZSQVHLCKE.

What about the NIE letter?

Replace X with 0, Y with 1 or Z with 2 and apply the same calculation to the resulting number.

Why are some letters not used?

I, Ñ, O and U are excluded because they could be confused with numbers or other letters.

Is it safe to type my DNI here?

Yes. The calculation runs in your browser, nothing is sent or stored, and the number is not included when sharing.