Spanish DNI/NIE Check Letter Calculator (Letra DNI Validator)
Free calculator to check and generate the check letter for a Spanish DNI (national identity number) or NIE (foreigner identity number). Enter just the number to calculate its check letter, or enter the full number with the letter to validate it. Everything runs right in your browser.
What is the Spanish DNI/NIE Check Letter Calculator?
This free online calculator checks and generates the check letter for a Spanish DNI (Documento Nacional de Identidad, or national identity number) or NIE (Número de Identidad de Extranjero, or foreigner identity number). It takes the 8-digit number (for a NIE, the leading X, Y, or Z is first read as 0, 1, or 2), divides it by 23, and uses the remainder to look up the check letter from a fixed 23-character table.
The tool automatically figures out what kind of input you've given — whether it's a DNI or a NIE, and whether a check letter is included — based on the leading character and whether a trailing letter is present, so there's no mode to switch manually. If a check letter is included, the tool validates it; if only the number is given, it calculates and fills in the correct check letter. Keep in mind that this tool only confirms whether the format is correct — it cannot determine whether the number was actually issued to a real person (that would require checking with an official Spanish government channel).
How to use it
- Enter your DNI or NIE You can paste it in with hyphens or periods still included.
- Check the detected type The detected type is shown (DNI or NIE, and whether a check letter was included).
- Review the result You'll see either the validation result or the calculated check letter.
- Try another number Use the Clear button to reset the input and check a different number.
Tips for getting more out of it
- You can paste the number with hyphens or periods still in place — those characters are stripped automatically before the calculation.
- Enter just the 8-digit number without a check letter and the tool will calculate the correct one for you automatically.
- A NIE is a 7-digit number that starts with X, Y, or Z. That leading letter is read as 0, 1, or 2 respectively before applying the same mod-23 formula used for a DNI.
- Lowercase letters are converted to uppercase automatically, so you don't need to worry about capitalization.
- This tool only checks whether the check letter matches the expected format — it can't confirm whether the number was actually issued to a real person. For that, you'd need to check with Spain's Ministerio del Interior (Ministry of the Interior) or another official channel.
Common use cases
Catching typos in checkout and payment forms
Before submitting an order on a Spain-facing online store or payment form, confirm that the entered DNI or NIE matches its check letter with no transcription errors.
Verifying entries for HR and admin staff
Before registering a new employee's or Spain-based staff member's DNI or NIE in an internal system, confirm it against its check letter.
A reference for building validation logic
Use it as a reference to confirm the expected behavior of DNI/NIE validation logic (the mod-23 calculation) when building forms or registration systems for a Spanish audience.
Digitizing older paper records
When entering DNI or NIE numbers from paper documents into a database, use the check letter to catch OCR misreads.
Glossary
- DNI (Documento Nacional de Identidad)
- An 8-digit national identity number issued to Spanish citizens. It's used for everyday purposes such as opening a bank account or proving one's identity.
- NIE (Número de Identidad de Extranjero)
- An identity number issued to foreign nationals who stay or reside in Spain. It begins with the letter X, Y, or Z.
- Check letter (Letra de Control)
- A single verification letter added to the end of a DNI or NIE number, calculated from a 23-character table to help catch input errors or typos.
- Mod 23 (remainder after dividing by 23)
- The formula used to derive the check letter: the 8-digit number is divided by 23, and the remainder is used as an index into a fixed 23-character table.
- Ministerio del Interior (Ministry of the Interior)
- The Spanish government body responsible for issuing DNIs and NIEs, as well as overseeing domestic security and administrative affairs.
Frequently asked questions
Side Note — the "divide by 23" formula used all across Spain
The DNI (Documento Nacional de Identidad, or national identity document) is an 8-digit number issued to Spanish citizens shortly after birth. It's used as proof of identity in nearly every corner of daily life in Spain, from opening a bank account and signing up for a mobile phone plan to voter registration and accessing public services. Foreign nationals who reside in Spain for an extended period are issued a NIE (Número de Identidad de Extranjero, or foreigner identity number) instead. It shares the same digit count and check formula as the DNI, differing only in that it begins with the letter X, Y, or Z.
The check letter (Letra de Control) works on a simple principle: take the remainder when the 8-digit number is divided by 23, and use it to look up a single character from a fixed 23-character table (TRWAGMYFPDXBNJZSQVHLCKE). For a NIE, the leading X, Y, or Z is first read as 0, 1, or 2 before the same calculation is applied. The 23-character table deliberately leaves out the vowels A, E, I, O, and U, along with easily confused characters (such as O and 0), which helps prevent misreadings when the letter is read aloud or copied by hand.
This scheme has remained largely unchanged since the 1970s, and many of Spain's official online forms still validate a submitted DNI or NIE's check letter with this exact formula on the spot. It's a little-known fact that the same logic often runs quietly behind the scenes not just at government offices, but also in identity-verification forms used by banks and online retailers.