NIE, NIF, DNI and CIF in Spain: what is the difference?

Carlos Cabello
Co-founder. Tech and Operations Lead
Published on 
31/7/2026
Contents

Open a bank account in Spain and someone will ask for your NIF. Sign a deed and the notary asks for your NIE. A Spanish supplier invoices you and quotes a CIF. Four acronyms, used interchangeably by people who should know better, and it is rarely clear whether they mean four different things or one thing with four names.

The short answer: they are different concepts, but they overlap in a way that is genuinely useful once you see it.

The four numbers in one paragraph each

DNI is the Documento Nacional de Identidad, the Spanish national identity document, governed by Real Decreto 1553/2005. Only Spanish nationals have one. It is both a physical card and the number printed on it: eight digits followed by a check letter.

NIE is the Número de Identidad de Extranjero, the identity number for foreigners, set out in article 206 of Real Decreto 557/2011. Any foreigner with an economic, professional or social connection to Spain gets one. Format: a letter X, Y or Z, then seven digits, then a check letter.

NIF is the Número de Identificación Fiscal, the tax identification number, regulated by Real Decreto 1065/2007. This is where the confusion starts, because the NIF is not usually a separate number at all.

CIF was the Código de Identificación Fiscal, the old tax code for companies. It no longer exists as a legal category.

The key insight: your NIE is your NIF

This single fact resolves most of the confusion. Under Real Decreto 1065/2007, a foreigner's NIE functions directly as their tax identification number. There is no second number to apply for and no separate NIF certificate to obtain.

The same logic applies to Spanish nationals: their DNI number is their NIF. So when a bank, a landlord or the tax office asks for your NIF and you are a foreigner, the answer is your NIE. When someone asks a Spaniard for their NIF, the answer is their DNI number.

NIF is best understood as a role rather than a number: it is whatever number you use for tax purposes. For you, that is your NIE.

And CIF? It was abolished

CIF was the tax code for companies and other legal entities. Real Decreto 1065/2007 folded it into the NIF system, so since 2008 Spanish companies have had a NIF, not a CIF.

Nobody told the Spanish business world. You will still see "CIF" on invoices, on contracts and in accounting software, and people still say it in conversation. It is not wrong in any practical sense, it is just outdated terminology. A company NIF starts with a letter indicating the entity type: A for a sociedad anónima, B for a sociedad limitada, G for an association, and so on, followed by seven digits and a check character.

How to read the number itself

The last character of a DNI or NIE is not decorative. It is a check letter, calculated from the digits, and it is what allows a bank's system to reject a mistyped number instantly.

The calculation is the same for both. Take the numeric part, divide by 23, and take the remainder. That remainder, from 0 to 22, points to a position in this fixed sequence:

T R W A G M Y F P D X B N J Z S Q V H L C K E

For a NIE, first replace the leading letter with a digit: X becomes 0, Y becomes 1, Z becomes 2. So a NIE beginning Y1234567 is treated as the number 11234567. Divide that by 23 and the remainder is 10. Counting from zero, position 10 in the sequence above is X, so the complete NIE is Y1234567X.

Notice which letters are missing: I, Ñ, O and U are deliberately excluded, because they are too easily confused with the digits 1 and 0, or with each other. If you see a NIE ending in one of those, something has been transcribed wrongly.

What the X, Y and Z actually mean

There is a persistent myth that the prefix tells you something about nationality, residency status or the region where the number was issued. It does not.

The letter is chronological. X was used until 15 July 2008. Y has been issued since 16 July 2008, under Orden INT/2058/2008. Z is held in reserve for when the Y series runs out.

So the letter tells you roughly when the number was assigned, and nothing else. Someone with an X is not more or less resident than someone with a Y.

Which document you actually receive

The number is one thing. The piece of paper or plastic proving you have it is another, and it depends entirely on your situation.

  • Non-resident foreigner who just needs the number. You receive a white A4 certificate stating your NIE. No photo, no card, nothing to carry in a wallet.
  • EU citizen living in Spain. You register on the Registro Central de Extranjeros under Real Decreto 240/2007 and receive the green certificate, the Certificado de Registro de Ciudadano de la Unión, which shows your NIE. It comes as an A4 sheet or a small green card.
  • Non-EU citizen resident in Spain. You receive a TIE, the Tarjeta de Identidad de Extranjero: a physical card with your photo, showing your NIE alongside a separate support number that changes each time the card is renewed.

Which brings us to a question we are asked constantly.

Is there such a thing as a NIE card?

No. There is no official document called a NIE card. When people use that phrase they mean either the white certificate, the green EU registration certificate or the TIE, depending on their situation.

This matters practically. If a Spanish bank or estate agent asks for your "NIE card" and you are a non-resident buyer, they are asking for your white certificate. Turning up expecting to have been given a plastic card is a common disappointment.

What expires and what does not

The NIE number itself never expires. It is assigned once and stays with you permanently, even if you leave Spain for twenty years and come back.

The documents are different. A TIE card carries an expiry date tied to your residence permit and must be renewed. The white non-resident certificate has no legal expiry, but in practice banks, notaries and the land registry often want one issued within the last three months. The green EU certificate does not expire in the way a TIE does; after five years of continuous residence you can apply for the permanent version.

The distinction worth remembering: your number is permanent, your paperwork is not.

A quick reference

  • Spanish national, any purpose: DNI number, which is also the NIF.
  • Foreigner, any purpose including tax: NIE, which is also the NIF.
  • Spanish company: NIF starting with a letter, still widely called a CIF.
  • Physical proof for a non-EU resident: TIE card.
  • Physical proof for an EU resident: green certificate.

Why Buenaley

Most people never need to know any of this until a notary refuses a document or a bank rejects a form. At that point it becomes urgent, and the difference between a NIE certificate and a green certificate suddenly costs you an appointment.

Buenaley is a Spanish law firm working with internationals on exactly these questions: identification numbers, property purchases, tax and residency. We tell you which number and which document your situation actually requires, before it becomes a problem.

  • Clear answers in your own language, without the jargon.
  • Experience with what banks, notaries and registries in Spain will and will not accept.
  • Practical help, from a first NIE to a full purchase.

Not sure which number you need, or need to apply for a NIE before a deadline? Get in touch and we will look at it with you.

Add us on Google
Share this article

No obligation to start.

First Consultation Free.

Will Call You
Gracias, hemos recibido tu solicitud.
Oops! Something went wrong while submitting the form.