NIF and DNI: Are they the same? Differences with NIE and TIE
NIF and DNI: are they the same? Differences with NIE and TIE!
Almost. The DNI is the physical document that proves your identity, and the NIF is the number with which Hacienda (the Spanish tax agency) identifies you. If you are Spanish and have a DNI, your NIF is your DNI number followed by its letter, so in practice you see the same eight digits and the same letter in both places. If you are a foreign national, your NIF is usually your NIE. And in some specific cases, the NIF is its own number starting with K, L or M.
This guide tells you what each thing is, when they match and when they do not, and which number you have to write on an invoice, a tax return or your registration as an autónomo (self-employed worker).
In summary
- The DNI is a document; the NIF is a tax number. For an individual of Spanish nationality, the NIF is the DNI number plus its letter.
- If you are a foreign national, your NIF is generally your NIE. The TIE is the physical residence card, not a different tax number.
- The DNI is the NIF, not the NIE. The NIE is for those who do not hold Spanish nationality.
- NIFs starting with K, L or M exist for specific cases: minors under 14, Spanish nationals residing abroad without a DNI and foreign nationals without a NIE.
- As an autónomo, on your invoices and tax returns you write your NIF exactly as it appears on your DNI or NIE, including the letter.
Table of contents
- DNI and NIF: the difference in one sentence
- What your NIF is depending on who you are
- Is the DNI a NIF, a NIE or neither?
- DNI, NIE and TIE: they are not three versions of the same thing
- When you need a K, L or M NIF
- And if you are a company: from the NIF to the former CIF
- How to find out your NIF and what to put on an invoice
- Common mistakes with the NIF, DNI and NIE
- Our perspective: the NIF is the key to everything else
- Leaving paperwork in the hands of an online gestoría
- Frequently asked questions
- Sources
DNI and NIF: the difference in one sentence
The DNI is a public, official, personal and non-transferable document that proves the identity and Spanish nationality of its holder. The NIF, on the other hand, is the identifier you need for your dealings with the tax authorities. It is not a card: it is a code.
The confusion stems from the fact that, for most Spanish nationals, that code is already printed on the DNI. The Agencia Tributaria explains that, for individuals of Spanish nationality, the NIF is their DNI number followed by the verification character. That is why no one asks you for a separate document to start paying taxes: Hacienda recognises you by the number you already have.
A simple way to look at it:
- DNI: the object (the card) and, at the same time, the number it carries.
- NIF: the tax use of that number.
- Letter: the final part of the number, which acts as a check character. It is part of the NIF, not an ornament.
How the letter is calculated
The letter is not random. It is obtained by dividing the DNI number by 23 and assigning a letter according to the remainder. With the classic example, 12345678 divided by 23 leaves a remainder of 14, which corresponds to Z: 12345678Z. If you want to check a number without doing the maths, you can use our NIF, NIE and CIF validator, which also calculates the letter.
What your NIF is depending on who you are
The NIF does not have just one format. It depends on your situation. This table summarises the cases for individuals according to what the Agencia Tributaria states:
| Situation | Your NIF is... | Typical format |
|---|---|---|
| Spanish national with DNI | The DNI number and its letter | 8 digits + letter |
| Foreign national with NIE | The assigned NIE | Initial letter + 7 digits + letter |
| Spanish national under 14 residing in Spain, without a DNI | K NIF | Starts with K |
| Spanish national residing abroad, without a DNI | L NIF | Starts with L |
| Foreign national without a NIE (temporarily or permanently) | M NIF | Starts with M |
The general rule for foreign nationals is that, for individuals without Spanish nationality, the NIF is the foreign national identity number (NIE) assigned or provided to them. The Agencia Tributaria itself summarises that, for an individual carrying out transactions of tax significance, the NIF will generally coincide with your DNI or NIE.
Is the DNI a NIF, a NIE or neither?
It is one of the most repeated searches, and the answer is clear: the DNI is the NIF, not the NIE. For an individual of Spanish nationality, the DNI number with its letter is their NIF. The NIE belongs to someone who does not have Spanish nationality.
The three terms get mixed up because they are written similarly, but they answer different questions:
- DNI: who are you and what nationality? (Spanish identity document).
- NIE: what identity number does a foreign national have in Spain?
- NIF: with which number do you identify yourself to Hacienda?
A Spanish national never has a NIE, and a foreign national with a NIE does not have a DNI unless they acquire Spanish nationality. When that situation changes, the number that appears as the NIF changes.
What happens if you have two numbers
It can happen that a person has a NIF assigned by the tax administration and, later, obtains a DNI or a NIE. The Agencia Tributaria establishes that in this case the DNI or NIE prevails and notification is given of the revocation of the previous NIF. A minor with a K NIF, for example, switches to using their DNI number when they obtain it.
DNI, NIE and TIE: they are not three versions of the same thing
If you are a foreign national, the TIE adds to the mix. Here the key is to separate the number from the card:
- NIE: is the foreign national identity number. It is the one you use as a NIF.
- TIE: is the Tarjeta de Identidad de Extranjero (foreign national identity card), the physical medium. According to the Sede Electrónica of the Policía Nacional, after entering Spain, a foreign national must apply for this card when obtaining a residence permit.
- DNI: only for those who hold Spanish nationality.
The TIE has your NIE printed on it, so when showing the card you are also giving your tax number. But the tax procedure asks for the number, not the card. That is why you can have a NIE, and therefore a NIF, without having collected the TIE yet.
In summary: DNI for Spanish nationals, NIE as the number for foreign nationals, and TIE as the card that accompanies it when there is residence.
When you need a K, L or M NIF
Most people will never see a NIF with these letters. They exist for those who need to operate with Hacienda without having a DNI or a NIE. The Agencia Tributaria details that, in certain cases, a NIF must be obtained by Spanish nationals residing abroad, minors under 14 and foreign nationals without a NIE, even if they are not required to hold a DNI.
Specifically:
- K NIF: Spanish nationals under 14 residing in Spain.
- L NIF: Spanish nationals residing abroad who do not have a DNI.
- M NIF: foreign individuals who lack a NIE, either temporarily or permanently.
The application is made using modelo 030 when the person is going to carry out transactions of tax significance and does not have to be part of the census of business owners, professionals and withholders. In the case of a minor under 14, a photocopy of the Libro de Familia (family record book) or the birth certificate is provided.
Note a detail that matters to autónomos: if you are going to register an economic activity, the procedure is the census registration of business owners and professionals, not modelo 030. If you have doubts about which number to use in that registration, our guide on registering as an autónomo online explains it step by step.
And if you are a company: from the NIF to the former CIF
The term NIF is also used for companies, and here there is no DNI involved. The NIF of Spanish legal entities and entities without legal personality has nine characters: a letter indicating the legal form, seven digits and a check character.
That number was formerly called CIF, and many people still use the name. Today it is just another NIF, only for an entity. This explains why you see invoices with "CIF" for a company and "NIF" for an autónomo, when for Hacienda it is the same concept.
If you are thinking of switching from an autónomo to a company, your personal NIF (the one from your DNI) does not disappear: the company will have its own, and you will keep yours.
How to find out your NIF and what to put on an invoice
If you are a Spanish national with a DNI, look at your card: eight digits and a letter. If you are a foreign national, it is the NIE that appears on your certificate or on your TIE.
If you want to confirm how Hacienda has you registered, the Agencia Tributaria offers «Mis datos censales» on its sede electrónica. It is accessed with electronic identification (electronic certificate, DNIe, Cl@ve Móvil or eIDAS) and shows your NIF and your identifying details, as well as your economic activities and obligations.
The NIF on your invoices
In invoicing, the NIF is not optional. According to the Agencia Tributaria, on a full invoice, the name and NIF of the issuer must appear as well as the name of the recipient; the recipient's NIF is needed in certain cases. A simplified invoice also includes the NIF and name or business name of the issuer.
For an autónomo, this translates into a practical rule: write your NIF exactly as it appears on your DNI or NIE, with the letter, without strange spaces or hyphens. A mistyped digit on an invoice is a problem for you and for your client, who may need it to deduct the expense.
If you issue invoices frequently, our free invoice generator lets you fill in your tax details just once. And if you need invoicing with VERI*FACTU, you have all the information in online invoicing for autónomos.
What to do if Hacienda does not recognise your NIF
Sometimes, when filing a tax form, a warning appears stating that the NIF is not identified. The Agencia Tributaria indicates that in that case you must check that you have written the NIF and name or business name correctly. The most common mistakes are an incorrect letter, an extra zero or the name in an order different from the census.
Common mistakes with the NIF, DNI and NIE
These are the stumbling blocks we see most often among those starting out as autónomos:
- Thinking that the NIF is a different number from the DNI. For a Spanish national, it is the same number. You do not have to "request" a separate NIF.
- Omitting the letter. Without it, the NIF is incomplete and may be rejected.
- Calling the DNI a NIE, or vice versa. The DNI belongs to Spanish nationals; the NIE, to foreign nationals.
- Confusing the TIE with the NIE. One is the card and the other, the number it carries.
- Using the wrong address alongside the NIF. Your NIF identifies the person; the tax address is another matter. If in doubt, review what the tax address is.
- Assuming an expired DNI is valid for everything. The document has an expiry date, but the tax number does not change upon renewal.
If you arrived in Spain from another country and wonder since when you pay taxes here, the NIF is only one part: where you reside also counts. You have it explained in our guide on tax residency in Spain.
Our perspective: the NIF is the key to everything else
When someone asks us if the NIF and the DNI are the same thing, the short answer is that they seem like it, and that is why they are underestimated. But that number is the key to everything that comes after: registration, invoices, IVA (Spanish VAT), IRPF (personal income tax), Renta (annual income tax return). An error in one letter carries over to every document you issue.
We believe that an autónomo should not have to think about these things. That is why at Melso we work with an artificial intelligence agent and a team of professionals: you write to us on WhatsApp, and your tax details are organised and reviewed before being filed. You approve the exact documents in the app, and you know what is sent to Hacienda.
In addition, we assume responsibility for recargos (surcharges) and penalties arising from our own errors in tax returns. It is our way of saying that small details, like a check letter, matter and we take care of them.
Albert
Leaving paperwork in the hands of an online gestoría
If you are starting out or have changed your situation (from employee to autónomo, from resident foreign national to autónomo with a NIE), the easiest option is to delegate the paperwork. At Melso, we offer an online gestoría (a private firm that handles tax and administrative paperwork) for autónomos in Spain: unlimited invoicing, expense management, preparation and filing of taxes (IVA, IRPF and Renta) and professional support in the app and by email. We also help you with registering as an autónomo, with replies to requerimientos (formal notices from Hacienda) and with switching from another gestoría.
Our Pro plan costs €49 a month, or €490 a year (equivalent to €40.83 a month), and you can see it on the pricing page.
If you prefer to start with the basics, you also have free tax tools and our tax guides for autónomos. And once your NIF is in order, quarterly procedures like modelo 303 (the quarterly VAT return) and modelo 130 for IRPF become routine.
Frequently asked questions
Are the NIF and DNI the same thing?
Not exactly, but for a Spanish national their number is the same. The DNI is the identity document; the NIF is the tax number, which for an individual of Spanish nationality is the DNI number with its letter. That is why you do not need to request a separate NIF to start paying taxes.
Is the DNI a NIF or a NIE?
The DNI is the NIF, not the NIE. The NIE is the identity number for foreign nationals, and functions as their NIF. A Spanish national has a DNI and a resident foreign national has a NIE; no one has both at the same time.
What NIF do I have if I am a foreign national?
In general, your NIE. The Agencia Tributaria indicates that for individuals without Spanish nationality, the NIF is the NIE assigned to them. If you do not have a NIE yet and need to operate with Hacienda, a NIF starting with M can be assigned.
What number do I put on my invoices as an autónomo?
Your NIF, that is, the full number of your DNI with the letter if you are Spanish, or your NIE if you are a foreign national. It is mandatory information for the issuer on a full invoice. Write it exactly as it appears on your document, to avoid rejections or mistakes when filing returns.
How do I know if my NIF is written correctly?
You can check the format with the NIF, NIE and CIF validator. To see how Hacienda has you registered, consult «Mis datos censales» on the Agencia Tributaria's sede electrónica using your electronic certificate or Cl@ve.
Sources
- Agencia Tributaria: NIF composition for individuals
- Agencia Tributaria: NIF of an individual
- Agencia Tributaria: forms to use and documentation for individuals
- Agencia Tributaria: Mis datos censales
- Agencia Tributaria: invoice content (full invoice)
- Agencia Tributaria: invoice content (simplified invoice)
- Agencia Tributaria: specific error messages
- La Moncloa: differences between DNI, NIE and NIF
- Policía Nacional: residence card, Sede Electrónica
- Universidad de Málaga: NIF composition


