Spain Tax ID Guide — NIF, DNI, NIE, CIF & NIF-IVA
Spain's tax identification number is the NIF (Número de Identificación Fiscal). Every person and entity with tax dealings in Spain has one (Ley 58/2003 General Tributaria, sixth additional provision), but it takes different forms: for a Spanish national it is the DNI number plus its check letter; for a foreigner, the NIE; for an individual with neither, a K, L or M number; and for a company or other entity, a letter-coded number formerly called the CIF. [1] Entity NIFs and K/L/M numbers are assigned by the Spanish Tax Agency (AEAT — Agencia Estatal de Administración Tributaria); the DNI and NIE are issued by the Ministry of the Interior through the Dirección General de la Policía. For intra-EU trade, a business registered in the ROI (Registro de Operadores Intracomunitarios) uses its NIF with the prefix ES — the NIF-IVA. For VAT rates, invoicing and filing, see the Spain VAT guide.
Spain's NIF Types at a Glance
| Type | Format | Who has it | Issued by | Check character |
|---|---|---|---|---|
| DNI-based NIF | 8 digits + letter — 12345678Z | Spanish nationals | Ministry of the Interior (Policía), with the DNI | Letter, modulus 23 (published) |
| NIE | X, Y or Z + 7 digits + letter — X1234567L | Foreign individuals | Ministry of the Interior (Policía) | Letter, modulus 23 (published) |
| K / L / M NIF | K, L or M + 7 characters + letter | Individuals with no DNI or NIE | AEAT (modelo 030) | Letter (method not published) |
| Entity NIF (formerly CIF) | Legal-form letter + 7 digits + control character — B12345674 | Companies and other entities; N = foreign entity, W = permanent establishment | AEAT (modelo 036) | Digit or letter (method not published) |
| NIF-IVA | ES + NIF — ESA28015865 | Businesses registered in the ROI only | AEAT (modelo 036, box 582) | As the underlying NIF |
DNI-Based NIF (Spanish Nationals)
| Field | Detail |
|---|---|
| Format | 8 digits + an uppercase check letter |
| Regex | ^\d{8}[TRWAGMYFPDXBNJZSQVHLCKE]$ |
| Example | 12345678Z — the Ministry of the Interior's worked example |
| Issued | With the national identity card (DNI) |
A Spanish national's NIF is their DNI number followed by its check letter (RD 1065/2007 art. 19.1) — eight digits alone are not a NIF. [2] The DNI is issued by the Ministry of the Interior through the Dirección General de la Policía (RD 255/2025 art. 2.1). It is compulsory for Spaniards over 14 who live in Spain, and for Spaniards abroad who move to Spain for more than six months. [3] [4]
NIE (Foreign Individuals)
| Field | Detail |
|---|---|
| Format | X, Y or Z + 7 digits + a check letter |
| Regex | ^[XYZ]\d{7}[TRWAGMYFPDXBNJZSQVHLCKE]$ (pre-July-2008 NIEs: ^X\d{8}[A-Z]$) |
| Example (synthetic, passes the check) | X1234567L |
| Issued | By the Policía — automatically in residence procedures, or on application |
The NIE (Número de Identidad de Extranjero) is a foreign individual's NIF. The Ministry of the Interior describes it as a letter (X, Y or Z), seven digits and a check digit. [5] The prefixes are used in sequence: when the X series ran out, issuing continued with Y. NIEs issued before 16 July 2008 had the form X + eight digits + letter, and they remain valid indefinitely (Orden INT/2058/2008). [17] The Policía assigns an NIE automatically when a residence or stay procedure is opened; a foreigner with economic, professional or social interests in Spain must apply for one, in Spain or through a Spanish consulate. [6]
K, L and M NIFs
Individuals who have neither a DNI nor an NIE receive a NIF from the AEAT: an initial letter, seven alphanumeric characters and an alphabetic check character (RD 1065/2007 arts. 19.2 and 20.2). [2]
- K — Spanish residents under 14 with no DNI.
- L — Spaniards resident abroad with no DNI.
- M — foreigners with no NIE. For someone who is obliged to hold an NIE, the M number is temporary and lapses after three months, or earlier when the NIE is issued; for someone who is not obliged to hold one (a diplomat, or a stay under three months), it is permanent.
Apply on modelo 030 at the AEAT or through a Spanish consulate. A foreign company's non-resident legal representative needs an M-NIF. [4]
Entity NIF (Formerly CIF)
An entity NIF has nine characters: a letter showing the legal form (or foreign status), a random seven-digit number, and a control character (Orden EHA/451/2008 art. 2). [7]
| Letter | Entity |
|---|---|
| A | Sociedad anónima (public limited company) |
| B | Sociedad de responsabilidad limitada (private limited company) |
| C | Sociedad colectiva (general partnership) |
| D | Sociedad comanditaria (limited partnership) |
| E | Comunidad de bienes, herencia yacente and other entities without legal personality |
| F | Cooperative |
| G | Association |
| H | Comunidad de propietarios (owners' community) |
| J | Sociedad civil (civil partnership) |
| N | Foreign entity |
| P | Local authority |
| Q | Public body |
| R | Religious congregation or institution |
| S | Organ of the State or regional administration |
| U | Unión temporal de empresas (joint venture) |
| V | Other types |
| W | Permanent establishment of a non-resident entity |
The letter key list is the one in force since 16 January 2016 (as amended by Orden HAP/5/2016). Since 2008 the seven digits are random and no longer encode the province, although older numbers were not renumbered. A real example is Telefónica, S.A.: A28015865. The entity NIF does not change unless the entity's legal form or nationality changes. [7] [8]

CIF and NIF are the same number. "CIF" was the entity code under Decreto 2423/1975, which RD 1065/2007 repealed from 1 January 2008. Most entities kept their nine characters; for those whose letter changed under the new keys, the AEAT was to notify a new NIF during 2008. [2] [7] The NIF itself has been Spain's single tax identifier since 1990; until 2008 an entity's NIF was its CIF code.
NIF-IVA (ES + NIF) and the ROI
For intra-EU transactions, the VAT number is the NIF with the prefix ES — for example ESA28015865. It is assigned only when the business asks to be included in the Registro de Operadores Intracomunitarios (ROI); if the AEAT has not decided within three months, the request may be treated as refused (RD 1065/2007 art. 25.1). [2] Inclusion is requested on modelo 036, ticking box 582 and giving the expected date of the first intra-EU operation in box 584. [9]
Some businesses are excluded from the ROI — among them businesses whose operations are all exempt without a right to deduct, farmers under the special agricultural scheme, and non-established businesses whose Spanish operations are all reverse-charged to the customer (art. 25.3). A valid Spanish NIF can therefore show as invalid in VIES simply because the holder is not in the ROI.

Check Characters
DNI and NIE — modulus 23 (official)
The Ministry of the Interior publishes the rule: [5]
- Divide the eight-digit number by 23 and take the remainder.
- Look up the remainder in this table:
| Remainder | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Letter | T | R | W | A | G | M | Y | F | P | D | X | B |
| Remainder | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Letter | N | J | Z | S | Q | V | H | L | C | K | E |
- For an NIE, first replace the initial X with 0, Y with 1 or Z with 2, then apply the same calculation.
Worked example: 12345678 ÷ 23 leaves remainder 14, so the letter is Z — 12345678Z. For the NIE X1234567L, 01234567 ÷ 23 leaves remainder 19, giving L.

Entity NIF — not officially published
The order that defines the entity NIF says only that it ends in "a control character", and the AEAT does not publish the method. The rule that validation libraries widely implement works on the seven digits: add the digits in positions 2, 4 and 6; double each digit in positions 1, 3, 5 and 7 and add the digits of each product; add the two totals; the control is 10 minus the last digit of the sum (0 if the sum ends in 0). It is written either as that digit or as the corresponding letter of JABCDEFGHI. For B12345674 the sums are 12 and 14, the total 26, and the control 4; for N1234567D the same digits give 4, written as D.
The AEAT's own lookup does reject numbers with a wrong control character, but it also rejects some numbers that pass this rule, so treat a passing result as a format check only. Which entity letters take a digit and which take a letter is likewise not officially documented.
Who Must Register for VAT
Spain has no VAT registration threshold. A person becomes a taxable business (empresario o profesional) from the moment it acquires goods or services with the intention, confirmed by objective evidence, of using them in a business activity (Ley 37/1992 del IVA art. 5.Dos), and commercial companies are presumed to be businesses. [10] Before starting, it must file a census declaration and obtain a NIF (art. 164.Uno; RD 1065/2007 art. 9.4). As at 13 October 2026, Spain had not adopted the EU small-business (SME) scheme of Directive (EU) 2020/285. See the EU VAT SME scheme explainer and the worldwide VAT registration thresholds table.

| Situation | Rule |
|---|---|
| Business established in Spain | Register (modelo 036) before starting activity — no threshold |
| EU seller of B2C distance sales of goods or telecom, broadcasting and electronic services into Spain | Taxed in the seller's own member state while its EU-wide total of such sales stays at or below EUR 10,000 in the current and preceding calendar year; above that, Spanish VAT applies, through the OSS or a Spanish registration (art. 73) |
| Non-established supplier selling B2B to a Spanish business | Usually no registration — the Spanish customer accounts for the VAT under the reverse charge (art. 84.Uno.2.a) |
| Non-established business that is itself liable for Spanish VAT | Must register and obtain a NIF (N-NIF for a foreign entity, W-NIF for a Spanish permanent establishment) |
| Taxable person established outside the EU | Must also appoint a tax representative, unless established in the Canary Islands, Ceuta or Melilla or in a state with equivalent mutual-assistance arrangements (art. 164.Uno.7.º) |
[10] The Canary Islands, Ceuta and Melilla are outside the Spanish VAT area (LIVA art. 3).
How to Register
- Businesses and entities file modelo 036, the census declaration, online — to register, request an entity NIF, join the ROI (box 582) and choose their VAT regime. An entity needs its deed of incorporation, its statutes and, where applicable, a certificate of registration in a public register; a provisional NIF can be issued while it is being incorporated. The NIF is assigned within ten days. [8] [2]
- Modelo 037, the simplified census declaration, was abolished from 3 February 2025 (Orden HAC/1526/2024); use modelo 036. [11]
- Individuals who are not in business use modelo 030 — which is also the route to a K, L or M NIF. [12]
For the general registration process across jurisdictions, see how to register for VAT, GST and sales tax.
E-Invoicing and the NIF
As at 2026-10-13, Spain issues no separate e-invoicing number — the NIF is the identifier. Under Real Decreto 238/2026, every e-invoice's unique code must include the issuer's NIF (art. 7.5), and the AEAT's public e-invoicing solution accepts an invoice only if the issuer's and recipient's NIFs are correctly stated (art. 11.3). [13]
| Obligation | Date |
|---|---|
| B2B e-invoicing — businesses with a volume of operations above EUR 8 million | 6 October 2027 |
| B2B e-invoicing — all other businesses | 6 October 2028 |
| Status and payment reporting by individuals and entities under the attribution-of-income regime with turnover up to EUR 8 million | 6 October 2029 |
| Veri*factu billing software — corporate income tax payers (in force) | 1 January 2027 |
| Veri*factu billing software — all other taxpayers (in force) | 1 July 2027 |
The B2B dates run from Orden HAC/1028/2026, in force since 6 October 2026. On 5 October 2026 the Ministry of Finance announced that the Veri*factu deadlines will move to October 2028; as at 2026-10-13 that change had not yet been published in the BOE, so the dates above remain in force. [14] See e-invoicing in Spain and the Veri*factu deadlines record.

How to Verify a Spanish NIF
| What you want to confirm | Official tool | What it returns |
|---|---|---|
| A business is in the ROI (has a NIF-IVA) | AEAT intra-community operator check — free, no login; enter the 9-character NIF without ES | A certificate stating whether an intra-community operator exists with that number, with a verification code — no name |
| A NIF-IVA is valid for intra-EU trade | EU VIES | Valid or invalid; Spain does not release the name or address |
| A domestic NIF matches a name | AEAT Comprobación de un NIF de terceros — requires Cl@ve, an electronic certificate or DNIe; up to 20,000 records | Identified, not identified, identified-deregistered or identified-revoked |
| A NIF has been revoked | AEAT revoked and rehabilitated NIF files — free download | Cumulative lists |
[15] Once a NIF's revocation is published in the BOE, the number loses its validity for tax identification, and banks must stop debits and credits on the holder's accounts until it is rehabilitated (Ley General Tributaria, sixth additional provision, para. 4). [1] [16]
"Not in VIES" does not mean "not a valid NIF" — only ROI-registered businesses appear there. For step-by-step checks, see how to verify a Spanish NIF and NIF-IVA. To check a NIF's format and check character instantly, use the Lookuptax Spain NIF validator.
Frequently Asked Questions
Is a CIF the same as a NIF?
Yes. CIF was the name of the company identification code under a 1975 decree. Since 1990 a company's NIF was its CIF code, and when that decree was repealed from 1 January 2008, the entity NIF was defined directly instead. Most companies kept the same nine characters. Entities whose letter changed under the new legal-form keys were to be notified of a new NIF by the AEAT during 2008.
A Spanish NIF shows as invalid in VIES. Is it fake?
Not necessarily. A Spanish business receives an ES-prefixed VAT number only once it has asked to be included in the Registro de Operadores Intracomunitarios (ROI), and some businesses are excluded, such as those making only exempt supplies or non-established businesses whose Spanish sales are all reverse-charged. A NIF that is not in the ROI is invalid in VIES even though it is a valid Spanish tax number.
Is there a VAT registration threshold in Spain?
No. A business is a taxable person from the moment it acquires goods or services intending to use them in its activity, and it must file modelo 036 and obtain a NIF before it starts. Spain has not adopted the EU small-business VAT exemption scheme. The only euro threshold that matters to most foreign sellers is the EUR 10,000 EU-wide limit for B2C distance sales and electronic services.
I'm a foreign director or investor without an NIE. Which number do I use?
You need a NIF beginning with M, which the AEAT assigns on modelo 030 or through a Spanish consulate. If you are obliged to hold an NIE, the M number is temporary and lapses after three months or when your NIE is issued. If you are not obliged to hold an NIE, it is permanent. A foreign company's non-resident legal representative also needs an M-NIF.
Can I check a Spanish NIF against a company name for free?
Only partly without Spanish electronic identification. The AEAT's intra-community operator check and VIES are open to anyone and confirm whether a NIF-IVA is registered, but neither returns the company's name. The AEAT service Comprobación de un NIF de terceros checks domestic NIFs and returns a company's registered name, but it requires Cl@ve, an electronic certificate or a DNIe. The AEAT's free downloadable files of revoked NIFs let you screen out revoked numbers.
Is modelo 037 still available?
No. The simplified census declaration, modelo 037, was abolished with effect from 3 February 2025 by Orden HAC/1526/2024. Businesses now register, update their details and deregister with modelo 036.
My foreign company sells to Spanish businesses. Does it need a Spanish NIF?
Often not for VAT. When a supplier not established in Spain sells to a Spanish business, the Spanish customer normally accounts for the VAT under the reverse charge. A foreign company does need a NIF when it is itself liable for Spanish VAT — for example on B2C sales above the EUR 10,000 EU-wide threshold without using the OSS. A taxable person established outside the EU must also appoint a tax representative.
Is the check character of a company NIF calculated like the DNI letter?
No. DNI and NIE letters use the officially published modulus-23 table. The control character of a company NIF uses a different rule that the AEAT has not published; validation libraries implement a Luhn-style calculation over the seven digits that produces either a digit or a letter. The AEAT lookup rejects numbers with a wrong control character.
Related Resources
- Spain VAT guide — rates, registration, invoicing and filing
- How to verify a Spanish NIF and NIF-IVA
- E-invoicing in Spain — FACe, Veri*factu and the B2B mandate
- How to verify an EU VAT number in VIES
- Spain tax changes — chronology
- Reverse charge explained
- Intra-community supply explained
- EU VAT One-Stop Shop (OSS)
- Worldwide VAT, GST and sales tax registration thresholds
- Global e-invoicing status tracker
- Portugal also calls its tax number "NIF" — see the Portugal tax ID guide
How Lookuptax can help you in VAT validation?
Lookuptax VAT validation revolutionizes VAT number validation with its robust platform, empowering businesses to seamlessly verify VAT numbers across over 100 countries. Our cutting-edge technology ensures accurate and efficient validation, reducing errors and enhancing compliance.