NIE vs NIF vs DNI vs CIF: Spanish ID Numbers Explained
Spanish forms ask for NIF, NIE or DNI, sometimes all three. What each number is, which one you have, and which one to write.

By Lorenzo, Spain Expat Consulting · Last checked: December 2026
Spanish forms ask for a NIF, an NIE, a DNI or sometimes a CIF. To a newcomer they look like four different numbers. In reality most foreigners have just one number that does several jobs. Understanding which is which saves confusion at banks, notaries and the tax office.
Short answer: The NIF (número de identificación fiscal) is the tax identification number everyone in Spain needs. For Spanish citizens it is the DNI number; for foreigners it is the NIE, a number starting with X, Y or Z. Companies have a NIF too, which used to be called the CIF. The TIE is the residence card that shows your NIE. Foreigners who need a tax number but have no NIE can get a NIF starting with M from the tax agency.
The numbers side by side
Number | What it is | Who has it | Issued by |
|---|---|---|---|
NIF | Tax identification number | Everyone with tax dealings in Spain | Tax agency (via DNI or NIE for individuals) |
DNI | Spanish national identity card and number | Spanish citizens | Police |
NIE | Foreigner identity number, starting with X, Y or Z | Foreigners with economic, professional or social links to Spain | Police |
NIF M | Tax number for foreigners without an NIE | Foreigners who need a tax number but no NIE | Tax agency |
CIF | Old name for a company’s tax number | Companies and entities | Tax agency |
TIE | Residence card showing the NIE | Non-EU residents | Police |
Sources: the Agencia Tributaria’s NIF page and its page on NIF K, L and M.
NIF: the umbrella term
The NIF is the number you use for anything tax-related: tax returns, invoices, property deeds, bank accounts and payslips. For individuals it is not a separate number. A Spaniard’s NIF is their DNI number plus letter; a foreigner’s NIF is their NIE. So when a form asks for your NIF and you are a foreigner, you write your NIE.
NIE: your number as a foreigner
The NIE is assigned by the police to foreigners who have economic, professional or social interests in Spain. It has the format of a letter (X, Y or Z), seven digits and a control letter. It is personal, and the number does not change. See how to get an NIE number in Spain.
DNI: only for Spanish citizens
The DNI is the identity document of Spanish nationals. Foreigners never receive a DNI unless they become Spanish citizens. At that point the DNI number replaces the NIE, and a certificate of concordance can link the two for banks and registries.
NIF M: the tax agency’s alternative
According to the Agencia Tributaria, foreigners who do not have an NIE, either temporarily or permanently, must ask the tax agency for a NIF starting with M when they need one for tax purposes. People staying in Spain for less than three months are not obliged to have an NIE. The M number can be requested through form 030, including by a non-presential procedure. In practice notaries and banks usually still ask for an NIE for property and accounts.
Not sure which number you need? Book an NIE consultation or WhatsApp Lorenzo.
CIF: a term that no longer officially exists
Companies used to have a CIF (código de identificación fiscal). Since 2008 the official term is NIF for companies too, although many people still say CIF. A Spanish SL has a NIF starting with B. A foreign company that needs a Spanish tax number gets a NIF starting with N. See NIE for foreign directors and shareholders.
TIE: the card, not the number
The TIE is the physical residence card for non-EU residents. It shows your NIE number. EU citizens receive a registration certificate with their NIE instead of a TIE. See NIE vs TIE and the EU registration certificate.
Which number to write on common forms
Situation | What to write |
|---|---|
Bank account | NIE (and passport) |
Property deed | NIE |
Spanish tax return | NIE as your NIF |
Employment contract and payroll | NIE, plus your Social Security number |
Company formation | Founders’ NIEs; the company gets its own NIF |
Car purchase | NIE |
Your Social Security number is yet another number; see NIE vs Social Security number.
Why the confusion causes real problems
Mixing up these numbers is not only a vocabulary issue. A bank that records your passport number in the tax identification field, or a notary who receives a NIF M when the registry expects an NIE, can create mismatches that take months to fix. Tax returns filed under one number and property registered under another make later sales and inheritances harder.
The simple rule: once you have an NIE, use it everywhere Spain asks for a NIF, and make sure every bank, employer, landlord and notary has the same number, spelled with the same letters and control digit. Keep a copy of your NIE document on your phone so you can check it when filling in forms.
Frequently asked questions
Is my NIE the same as my NIF?
Yes. For foreigners, the NIE works as the NIF for tax purposes.
Can I get a DNI as a resident?
No. The DNI is only for Spanish citizens.
What do the letters X, Y and Z mean?
They are simply series. Older NIEs start with X; newer ones with Y and then Z.
I have a NIF M. Do I still need an NIE?
It depends on what you need it for. For property purchases and long stays, an NIE is normally expected.
Get the right number first
We help you choose and obtain the right number. Book an NIE consultation or WhatsApp Lorenzo.
This article is general information, not legal or tax advice. Fees, thresholds and procedures change, so check the official sources linked above or speak to us before you act.
Need help applying this information to your circumstances? Speak with Spain Expat Consulting about the assistance available for your next steps.