NIF in Spain: Your Spanish Tax ID, the NIE and How to Get One

Which number is your tax ID in Spain, how to get a NIE or a NIF M and how to use it with the Agencia Tributaria.

Updated on:
October 29, 2026
TL;DR

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.

Table of contents:

What is the NIF in Spain?

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.

NIF, NIE, DNI, TIE and CIF: which one is your tax identification number?

Here's the number that works as your Spanish tax ID in each situation:

Your situationYour tax IDFormatWho assigns it
Spanish with a DNIYour DNI number and its letter8 digits and a letterMinisterio del Interior, with your DNI
Spanish living abroad without a DNINIF starting with LL, 7 letters or digits, check letterAgencia Tributaria
Spanish child under 14 living in Spain without a DNINIF starting with KK, 7 letters or digits, check letterAgencia Tributaria
Foreigner with a NIEYour NIEA letter, 7 digits and a letterPolicía Nacional, in Spain or through a Spanish consulate
Foreigner without a NIENIF starting with MM, 7 letters or digits, check letterAgencia Tributaria
Company or other entityIts 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)
  • TIE and NIE: the TIE (tarjeta de identidad de extranjero) is the card that proves your legal status in Spain; the NIE is the number it carries. More on the differences between DNI, TIE and NIE (in Spanish).
  • CIF is the old name for a company's tax number, regulated by a 1975 decree repealed since 1 January 2008. Today it's simply the company's NIF. Individuals, autónomos (self-employed) included, never had a CIF.

Who needs a Spanish tax ID and what it is used for

Anyone who does something with tax relevance in Spain needs a NIF, resident or not. You'll be asked for it when:

  • You file anything with Hacienda. Every return, notice or letter must carry your NIF. Without one, you must apply for it: if 10 days pass after filing with no proof that you've applied, Hacienda can treat it as not submitted, after a formal decision.
  • You get paid. Give it to whoever pays you work income from Spain (a salary, for example) or investment income, such as interest and dividends, paid in Spain or coming from assets held in Spain.
  • You buy or sell property. The notary asks for it when you sign the deed.
  • You take out insurance, a pension plan or investment funds. Accident policies of up to three months and fund transactions through an accredited non-resident's account are exceptions.
  • You bank in Spain. You can open an account without it, but you must provide it within 15 days and the account can't be used until you do. Accounts of people who have proved to the bank that they're not resident in Spain (with a tax residence certificate from their country, for example) are exempt, unless the income is paid to an establishment the holder has in Spain.
  • You're self-employed. Your NIF, and that of the people you deal with, goes on every document with tax relevance you issue.
💡 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.

How to get a NIE 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.

  • Starting a procedure to stay in Spain or with an immigration file: the police assign it automatically.
  • Economic, professional or social ties (a home, an inheritance or an investment, for example): you apply yourself, and you'll only get it if you're not in Spain irregularly and you explain why you need it.
  • EU or EEA citizen staying over three months: register in person in the Registro Central de Extranjeros (Central Register of Foreigners) within three months of arriving, at your province's immigration office or, if there isn't one, the police station. You get a certificate of registration on the spot, with your NIE.

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.

How to get a NIF without a NIE: NIF M and NIF L

If you need a Spanish tax ID but have no NIE or DNI, the Agencia Tributaria assigns its own NIF:

  • NIF M: foreigners without a NIE who are going to do something with tax relevance, whether temporarily (they must have a NIE but don't yet) or permanently (they're not required to).
  • NIF L: Spaniards living abroad without a DNI.
  • NIF K: Spanish children under 14 living in Spain without a DNI.

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.

Got a NIE or DNI after your NIF M, L or K? Tell the Tax Agency within two months

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.

How to identify yourself to the Tax Agency with a NIE

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:

  • With a NIE: the support number (número de soporte) on your foreigner card, residence permit or EU citizen certificate. It isn't your NIE.
  • With a DNI: its expiry date or, if it's permanent, its date of issue.

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.

Common mistakes with your Spanish tax ID

  1. Applying for a NIF when you have a NIE. Your NIE is your NIF; there's no second tax number to request.
  2. Using your personal number for your company. A company has its own NIF, and that's the one on the documents it issues. “CIF” is just its pre-2008 name.
  3. Mixing up the support number and the NIE. They're two different numbers.
  4. Thinking your NIE has expired. What expires is the TIE, which lasts as long as your authorisation. The NIE is your personal, unique and exclusive number.
  5. Switching numbers without checking. From a NIF M to a NIE, you have two months to report it. If you become Spanish and swap your NIE for a DNI, check which number Hacienda has you under before your next return.

Penalties linked to your tax ID

The Ley General Tributaria sets two fixed fines related to the NIF:

  • €150 (minor offence) for not meeting the obligations on using it, such as putting it on your returns and letters to Hacienda or giving it to your payer, the notary or your bank.
  • €30,000 (very serious offence) for giving false or falsified information when applying for a NIF, provisional or definitive.

Official sources

Frequently asked questions

Is the NIE the same as the TIE?
No. The TIE (tarjeta de identidad de extranjero) is the card that proves your legal status in Spain, and the NIE is the number it carries. The NIE is a personal, unique and exclusive number assigned by the Policía Nacional, while the TIE is valid for as long as the authorisation behind it and is replaced when that authorisation is renewed.
Do I need to renew my NIE?
What has an expiry date is the card. A TIE is valid for as long as the authorisation or right that justified it, loses its validity with it and is replaced by a new card when you renew. The NIE is a personal, unique and exclusive number that identifies you.
Can I apply for a NIE online?
The immigration regulation says you request the NIE in person: from the Dirección General de la Policía, directly or through an immigration office or a police station, or through a Spanish consulate if you are abroad. The NIF M is different: if you have no NIE and need a tax number, someone with a registered NIF and a digital certificate, DNIe or Cl@ve can request it from the Agencia Tributaria online on your behalf, attaching the documents it asks for, including a police document.
Can I get a Spanish tax ID from outside Spain?
Yes. You can request a NIE through a Spanish consulate, which passes your application to the Comisaría General de Extranjería y Fronteras. If you have no NIE, you can get a NIF M through the Agencia Tributaria's electronic register without going to an office: someone with a registered NIF who logs in with a digital certificate, DNIe or Cl@ve files it for you, with the documents the Tax Agency asks for, including a police document showing that you've applied for a NIE or that you're not required to have one.

Your Spanish tax ID, sorted

  • Your NIE is your NIF. No second tax number needed.
  • No NIE? The Agencia Tributaria assigns a NIF starting with M; the NIE itself comes from the Policía Nacional.
  • One number on file. Got a NIE after a NIF M? Tell Hacienda and everyone who needs it within two months.

Next up is usually your tax return: our tax return service for foreigners helps you file it without headaches. Start for free with TaxDown.

Author
TaxDown Team
Your tax return, done right
Follow me here
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

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.

Related articles

Download our app

File your tax return from wherever you are.

QR code to download the TaxDown app
Person using their mobile phone to file their tax return
Foreigners in Spain
Tax registration from 35€.
See my case