Spanish DNI / NIE / CIF Checker
Work out the control letter of a DNI or NIE, check whether a CIF's control character is right for its entity type, or validate a whole pasted list at once. Everything is computed in your browser - no identity or tax number is ever sent anywhere.
Todo se calcula en tu navegador. The mod-23 and CIF algorithms run locally in this page - no DNI, NIE or CIF is ever uploaded, stored or sent to a server.
Enter a DNI, NIE or CIF
What the first letter of a CIF means
Types N, P, Q, R, S and W always end in a letter; A, B, E and H always end in a digit; the rest accept either form.
The three numbers, and how each is checked
DNI - eight digits and a letter. Divide the eight digits by 23 and use the remainder to index the string TRWAGMYFPDXBNJZSQVHLCKE. The letters deliberately exclude I, Ñ, O and U so they can't be confused with 1 or 0.
NIE - the foreigner's number, nine characters starting with X, Y or Z. Replace that prefix with 0, 1 or 2 respectively and the DNI rule applies unchanged. X was used until July 2008, Y since then, with Z held in reserve. A common mistake is dropping the prefix before dividing, which gives the wrong letter every time the prefix isn't X.
CIF - the entity code: a letter for the organisation type, two digits for the province, a five-digit serial and a control character. The control is a Luhn-style sum over the seven body digits: double the digits in odd positions and add the digits of each product, add the even-position digits untouched, then take (10 - total mod 10) mod 10.
The part most free tools get wrong is what happens next. Whether that control is written as the digit or as its letter (0 = J, 1 = A, 2 = B and so on) depends on the entity type: N, P, Q, R, S and W always use the letter; A, B, E and H always use the digit; the rest accept either. This tool enforces the right form per type, and tells you when a number has the correct value in the wrong form.
Frequently asked questions
¿Cómo calcular la letra del NIE gratis?
Ve a la pestaña "Calculate the letter", escribe la X, Y o Z seguida de los siete dígitos y la letra aparece al instante, con la operación explicada. El truco está en sustituir el prefijo por un número antes de dividir: X vale 0, Y vale 1 y Z vale 2. Después se divide entre 23 y el resto indica la letra en la tabla TRWAGMYFPDXBNJZSQVHLCKE. Todo se calcula en tu navegador, sin enviar el número a ningún servidor.
¿Cómo funciona el validador de CIF español?
El CIF se compone de una letra de tipo de entidad, dos dígitos de provincia, cinco de número correlativo y un carácter de control. El control se calcula duplicando los dígitos de las posiciones impares y sumando las cifras del resultado, sumando los de posiciones pares, y aplicando (10 - suma mod 10) mod 10. Si la entidad es N, P, Q, R, S o W el control es una letra; si es A, B, E o H es un número; el resto admite ambos. Esta herramienta comprueba la forma correcta según el tipo.
Is my DNI or NIE sent to a server?
No. The mod-23 calculation and the CIF algorithm are JavaScript running inside this page. There is no network request, nothing is logged and nothing is stored - you can turn off your internet connection and the tool still works. Spanish identity numbers are personal data under the GDPR, and there is no reason to transmit one just to do arithmetic on it.
Can I bulk check a list of DNIs, NIEs and CIFs?
Yes. Paste a mixed list - one per line, or a CSV/TSV column - and every row is classified as DNI, NIE, CIF or K/L/M NIF on its own, then checked. You get a per-row verdict with the specific reason for each failure, a summary that counts each type, a filter to show only the problems, and a CSV export of the whole table.
What are K, L and M numbers?
They're personal NIFs for people without a DNI or NIE: K for Spanish nationals under 14, L for Spanish nationals living abroad, and M for foreign nationals who have no NIE. All three use the same mod-23 rule as a DNI, applied to the seven digits between the leading letter and the control letter. This tool recognises and validates them.
Why is my CIF rejected when the control character looks right?
Almost always because it's in the wrong form. The computed value can be written either as a digit or as its corresponding letter, and the entity type decides which is allowed. A CIF starting with P, for example, must end in a letter - the same value written as a digit is invalid, even though most online validators accept both. When that happens this tool says so explicitly and shows the form you should be using.
Does a valid letter mean the DNI belongs to a real person?
No. The control letter is a typo-detection device, nothing more. Any eight digits produce a valid-looking DNI once you append the right letter. It proves the number is well-formed; it says nothing about whether it was issued or to whom. Only the Policía Nacional (for a DNI or NIE) or the AEAT census (for a CIF) can confirm that.
What does the province code in a CIF tell me?
The second and third characters indicate the province where the entity was registered - 28 for Madrid, 08 for Barcelona, 46 for Valencia and so on. This tool names the province for you. Codes of 53 and above are used for non-resident entities and special registrations rather than a geographic province.
Why does the DNI letter table skip I, Ñ, O and U?
To avoid ambiguity. I and O are easily mistaken for the digits 1 and 0 on a printed or handwritten document, U can be confused with V, and Ñ isn't available on every keyboard or character set. Twenty-three letters remain, which is why the algorithm uses modulo 23.