NIE and DNI letter calculator
Type a Spanish NIE or DNI number and get its check letter instantly. Include the letter and we tell you whether the number is valid. Free, no sign-up, and the number never leaves your browser.
NIE: X, Y or Z followed by 7 digits. DNI: 8 digits. Add the final letter if you want it checked.
X is replaced by 0: 01234567 ÷ 23 = 53,676, remainder 19 → in the table, 19 is L.
| Typed | Correct | Status |
|---|
How it works
- Type the number: a NIE (X, Y or Z plus 7 digits) or a DNI (8 digits). Spaces, dots and hyphens are ignored.
- Read the check letter and the full number, ready to copy into a form.
- If you typed the letter too, we tell you whether it is correct, and show the right one if it is not.
What the NIE is
The NIE (Número de Identidad de Extranjero) is the identity and tax number Spain gives to foreigners. You need it to rent a flat, open a bank account, sign an employment contract, buy property, register as self-employed or pay taxes. It looks like X1234567L: a starting letter, seven digits and a final check letter.
That final letter is not random. It is calculated from the rest of the number, so a typo (a wrong digit or two swapped digits) almost always produces a different letter. That is why online forms, banks and the tax agency reject a NIE whose letter does not match.
How the NIE check letter is calculated
The method is published by Spain’s Ministry of the Interior and takes three steps:
- Replace the first letter with a digit: X = 0, Y = 1, Z = 2.
- Divide the resulting 8-digit number by 23 and keep the remainder (0 to 22).
- Look up the remainder in the table below. That letter goes at the end.
| NIE | Number divided | Remainder | Full NIE |
|---|---|---|---|
| X1234567 | 01234567 | 19 | X1234567L |
| Y1234567 | 11234567 | 10 | Y1234567X |
| Z1234567 | 21234567 | 1 | Z1234567R |
Check letter table (remainder of dividing by 23)
| Remainder | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Letter | T | R | W | A | G | M | Y | F | P | D | X | B |
| Remainder | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Letter | N | J | Z | S | Q | V | H | L | C | K | E |
The letters I, Ñ, O and U never appear as a check letter, because only 23 letters fit. A NIE or DNI ending in one of them is always wrong.
The Spanish DNI letter
Spanish citizens have a DNI instead: eight digits and a check letter, calculated the same way without the first step. For 12345678, the remainder of dividing by 23 is 14, so the letter is Z (12345678Z). The calculator above accepts both formats.
Common NIE problems
- A form says your NIE is invalid. Check the letter here first. If it is correct, the form may want the number without the leading X, with an extra zero (X01234567) or with no spaces.
- Old NIEs with eight digits. Some early NIEs were written as X plus eight digits, starting with 0. Drop that leading zero and the check letter is the same.
- NIE vs TIE. Your TIE card can expire and be renewed, but the NIE printed on it stays the same for life.
A matching letter only shows the number is well formed. It does not prove that the NIE exists or who it belongs to. If you are moving to Spain, our net salary calculator and self-employed calculator show what you would take home after Spanish tax.
Frequently asked questions
How is the NIE letter calculated?
Replace the first letter with a digit (X = 0, Y = 1, Z = 2), so you get an 8-digit number. Divide it by 23 and take the remainder, which is between 0 and 22. The remainder points to a letter in this list: TRWAGMYFPDXBNJZSQVHLCKE. For example, X1234567 becomes 01234567, the remainder is 19 and the letter is L, so the full NIE is X1234567L.
How do I check if a NIE number is valid?
Calculate the check letter for the number and compare it with the last letter of the NIE. If they differ, the number has been mistyped: a digit is missing, two digits are swapped or the letter is wrong. A matching letter only proves the number is well formed. It does not prove the NIE exists or belongs to a particular person.
What is the difference between the NIE and the TIE?
The NIE is your foreigner identity number in Spain, and it stays the same for life. The TIE is the physical residence card issued to non-EU residents, and it shows your NIE. EU citizens usually get a green registration certificate with the NIE printed on it. The number and its check letter are the same on every document.
Why does my NIE start with X, Y or Z?
NIEs issued before July 2008 start with X. Once the X series was used up, new NIEs started with Y, and Z is reserved for when the Y series runs out. The starting letter has no other meaning. It does not tell you the holder’s nationality or residence status.
How is the Spanish DNI letter calculated?
The same way, without the first step: divide the 8-digit DNI number by 23 and look up the remainder in the table. For example, 12345678 leaves a remainder of 14, which is Z, so the DNI is 12345678Z.
Is the number I type stored or sent anywhere?
No. The calculation runs in your browser with JavaScript and the number never leaves your device. It is not sent to any server or saved. The tool keeps working even with your internet connection switched off.