Validate a Spanish NIF or CIF
Check the format and control letter of a NIF, NIE or CIF, in your browser, for free.
Try an example
This checks the format and control letter only. It does not confirm the number is registered with Spain's tax agency (Agencia Tributaria).
Where do you need this?
How the NIF, NIE and CIF are built
A NIF for a Spanish individual is 8 digits followed by one control letter, for example 12345678Z. The letter is not random: it comes from dividing the 8-digit number by 23 and looking up the remainder in a fixed table of 23 letters.
A NIE, for foreigners resident in Spain, follows the same idea but starts with X, Y or Z instead of a digit, for example X1234567L. That starting letter is turned into 0, 1 or 2 before the same calculation runs.
A CIF, for companies and other organisations, starts with a letter that shows the legal form (for example A for a public limited company, B for a limited company), followed by 7 digits and one final control character. Depending on the first letter, that last character is a digit, a letter, or either one — this checker works out which rule applies and runs the same sum the tax office uses.
Frequently asked questions
Is a NIF the same as a CIF?
No. A NIF identifies an individual. A CIF identifies a company or other legal entity. Since 2008 companies technically get a NIF too, but almost everyone still calls a company's number a CIF, and this checker accepts both.
What is a NIE?
A NIE is the tax number for a foreigner living in or doing business in Spain. It has the same length as a NIF but starts with X, Y or Z.
Does a valid result mean the number is real?
No — see the note below the checker. It means the format and control letter match. Only Spain's tax agency (Agencia Tributaria) can confirm a number is actually assigned to someone.
Why does the checker reject a number with the right length?
The most common reason is the control letter. Mistype even one digit and the calculated letter changes, so the whole number is rejected — that's the control letter doing its job.
Related article: Cómo pedir el NIF o CIF en el checkout de Shopify sin tener Plus (article in Spanish)
Need this on your Shopify store?
Fiscal ID adds this exact validation to your cart, on any Shopify plan — no theme code, no Plus required.