DNI, NIE and CIF validator
Check the validity of a Spanish ID document and compute its check letter instantly.
Compute DNI letter
Compute NIE letter
Validation is purely arithmetic (mod 23 for DNI/NIE and the CIF control algorithm). It does not query any official registry or verify that the document exists.
Built by
Miguel Ángel Colorado Marin (MACM)
Built by
Miguel Ángel Colorado Marin (MACM)
Full-Stack Developer · Guadalajara, España
I develop web apps, digital tools and full projects — from design to deployment.
Checking by hand whether a DNI is correct means remembering the letter table, and the CIF has a different rule depending on the entity's first letter. This tool applies the official algorithm: for DNI and NIE, the number modulo 23 picks the letter from the TRWAGMYFPDXBNJZSQVHLCKE table; for NIE the X, Y or Z is replaced by 0, 1 or 2 before calculating. The CIF adds the digits in even positions plus twice those in odd positions, and derives the control digit by complement to 10. It is all local arithmetic, without querying any registry.
Features
- ✓Validation of DNI (8 digits and a letter), NIE (X/Y/Z, 7 digits and a letter) and CIF
- ✓Check letter computed with the official mod 23 table
- ✓CIF algorithm with a digit or letter control depending on the entity type
- ✓DNI and NIE generator from a number
- ✓Reason detection when the document is not valid
How do I validate a DNI, NIE or CIF?
- 1
Type the document
Enter the DNI, NIE or CIF with or without spaces; it normalizes itself.
- 2
Read the verdict
You get whether it is valid, the detected type and, if it fails, the correct letter or digit.
- 3
Generate if needed
Use the generators to get a well-formed DNI or NIE from a number.
- 4
Copy the result
Click the generated result to copy it to the clipboard.
Frequently asked questions
How is the DNI letter calculated?
The 8-digit number is taken, the remainder of dividing it by 23 is calculated, and that remainder indexes the string TRWAGMYFPDXBNJZSQVHLCKE. For example, 12345678 gives remainder 14, which corresponds to the letter Z.
How does the NIE differ from the DNI?
The NIE starts with X, Y or Z instead of being purely numeric. To validate it, that letter is replaced by 0, 1 or 2 respectively and the same calculation as the DNI is applied. For example, X0000000T is valid.
What is the CIF and how is it validated?
The CIF identifies legal persons and entities. It has an initial letter, 7 digits and a control that may be a digit or a letter depending on the entity type (for example, A, B, E and H use a digit; K, P, Q and S use a letter). The control is obtained by adding the even-position digits and twice the odd-position ones and taking the complement to 10.
Does it verify that the document really exists?
No. Validation is arithmetic: it confirms that the format and control are correct, but it does not query any official registry or guarantee that the person or company exists.
Related tools
Embed DNI, NIE and CIF Validator on your site
Add DNI, NIE and CIF Validator to any web page with a simple iframe. Free, with attribution to miguelacm.es.
<iframe
src="https://miguelacm.es/embed/dni-nie-validator"
width="100%"
height="700"
frameborder="0"
title="DNI, NIE and CIF Validator — miguelacm.es"
></iframe>View embed in new tab →