Your NIF in Spain is your tax ID, and which number it is depends on your case. Spanish with a DNI: your DNI number and its letter. Foreigner with a NIE: your NIE. Foreigner without a NIE: a NIF starting with M, which you ask the Agencia Tributaria for. The NIE itself comes from the Policía Nacional, not from the Tax Agency.
Just arrived in Spain, buying a flat or starting a job here, and everyone asks for your NIF in Spain? Short answer: if you're a foreigner with a NIE (foreigner identity number), your NIE is your Spanish tax ID; if you're Spanish, it's your DNI (national ID card) number with its letter. Only if you have neither do you need a separate NIF from the Agencia Tributaria, Spain's Tax Agency.
Here's which number is yours, how to get it and how to use it with Hacienda, the Spanish tax authorities.
The NIF (número de identificación fiscal) is the number that identifies you to the Spanish tax authorities in anything with tax relevance. Every individual and company has one, and so do entities without legal personality, such as a comunidad de bienes (co-ownership). The State administration gives it, on its own initiative or when you apply. The rules are in the Ley General Tributaria and in Real Decreto 1065/2007.
Individuals don't usually get a separate tax number. A Spaniard's NIF is their DNI number plus its check letter, and a foreigner's NIF is their NIE. Only people with neither get a NIF straight from the Agencia Tributaria, starting with K, L or M.
💡 If a bank, employer or notary asks for your “NIF” and you have a NIE, give them your NIE.
Here's the number that works as your Spanish tax ID in each situation:
| Your situation | Your tax ID | Format | Who assigns it |
|---|---|---|---|
| Spanish with a DNI | Your DNI number and its letter | 8 digits and a letter | Ministerio del Interior, with your DNI |
| Spanish living abroad without a DNI | NIF starting with L | L, 7 letters or digits, check letter | Agencia Tributaria |
| Spanish child under 14 living in Spain without a DNI | NIF starting with K | K, 7 letters or digits, check letter | Agencia Tributaria |
| Foreigner with a NIE | Your NIE | A letter, 7 digits and a letter | Policía Nacional, in Spain or through a Spanish consulate |
| Foreigner without a NIE | NIF starting with M | M, 7 letters or digits, check letter | Agencia Tributaria |
| Company or other entity | Its own NIF (often still called CIF) | 9 characters; the first letter shows the legal form (A: sociedad anónima, B: sociedad limitada, N: foreign entity) | Agencia Tributaria (in the Basque Country, the tax authority of its tax domicile; a non-resident entity without a permanent establishment and without a NIF asks the one of the territory where it operates) |
Anyone who does something with tax relevance in Spain needs a NIF, resident or not. You'll be asked for it when:
💡 Living in the UK and buying a holiday flat on the Costa del Sol? Sort out your tax ID well before you sign at the notary.
Next, check which foreign residents have to file a tax return or browse our tax guides for foreigners in Spain.
The NIE (número de identidad de extranjero, foreigner identity number) doesn't come from the Tax Agency: it's assigned by the Policía Nacional, through its Dirección General de la Policía.
You apply in person to the Dirección General de la Policía, directly or through an Oficina de Extranjería (immigration office) or a police station. From abroad, you apply through a Spanish consulate. The authorities have five days from registering your application to decide and notify you; if you hear nothing, it's considered refused. If you need to pay a police fee, here's how to fill in and pay the tasa 790 012.
If you need a Spanish tax ID but have no NIE or DNI, the Agencia Tributaria assigns its own NIF:
The NIF M is a tax number: it identifies you to Hacienda, but it isn't a general substitute for the NIE.
You apply with the modelo 030. On paper, you hand it in or post it to the Agencia Tributaria office for your tax address. Without going to an office, even from abroad, the signed and scanned 030 and your documents go through the Tax Agency's electronic register. Whoever files it needs a registered NIF and a digital certificate, DNIe (electronic ID card) or Cl@ve (the government's online login system), and can file on someone else's behalf, so if you have no NIF yet, someone who qualifies files it for you.
The documents depend on the type of NIF (see the Agencia Tributaria's “Informador censal”). For a NIF M, the Tax Agency asks for a document from the police: proof that you've applied for your NIE if you must have one, or proof that you're not required to have one. Missing, incomplete or inaccurate documents can get your application shelved. If you applied remotely, the NIF card notice goes to your tax or notification address, and with a phone or email you also get a code (CSV) to print the card.
Starting a business? The 030 isn't valid if you must join the Censo de Empresarios, Profesionales y Retenedores (the business census), for example as a freelancer. That census has its own declaration, the modelo 036.
📌 Example: Tom lives in Ireland, has no NIE and needs a Spanish NIF. Once he has signed his modelo 030 and has the police document, a relative in Spain with a NIF and Cl@ve can file it online for him.
A NIF from the Tax Agency (K, L or M) is valid only until you get a DNI or NIE. If you must have a NIE, the Agencia Tributaria limits a temporary NIF M to three months in general, and the expiry date appears on the document that proves it. Once you get your DNI or NIE, you have two months to tell the Agencia Tributaria and everyone who must have your new number, such as your bank or whoever pays you. Your old NIF works until the date you report the new one.
If the Tax Agency spots both numbers, the DNI or NIE prevails and it notifies you that the old NIF is no longer valid.
To log in to the Agencia Tributaria with your number and a check detail (dato de contraste), or to register for Cl@ve, you're asked for:
Here's where to find your NIE support number (in Spanish).
The same goes for the reference number (número de referencia) of the Renta 2025, the income tax return filed in 2026: with a NIE you gave your support number, and with a NIF K, L or M your date of birth, plus box 505 of your 2024 return or, if you didn't file one, the IBAN of a Spanish bank account you held on 31 December 2025. Each campaign sets its own rules.
No digital certificate? You can register for Cl@ve online with an invitation letter posted to your tax address, whose code (CSV) you must use within 60 days, or by video identification in the Cl@ve app.
💡 The slip we see most often when helping foreign residents with their tax returns: typing the NIE where the support number is asked.
The Ley General Tributaria sets two fixed fines related to the NIF:
Next up is usually your tax return: our tax return service for foreigners helps you file it without headaches. Start for free with TaxDown.
TaxDown is the Spanish platform that helps you file your income tax return easily, quickly and with maximum savings. It's a social collaborator of the Agencia Tributaria (Spanish Tax Agency) and has more than 300 expert tax advisors who review every return.