How to verify NIF Number in Spain?
This post is also available in: Español
NIF check on Agencia Tributaria website
The Agencia Tributaria (Spain's Tax Agency) provides a free intra-community NIF-IVA verification service. Important limitation: this portal only returns results for companies registered in the Registro de Operadores Intracomunitarios (ROI) — Spain's register of businesses authorised for intra-EU trade. Spanish companies that trade exclusively domestically will not appear here even if their NIF is valid (see FAQ below).
- Access the Tool: Go to the Agencia Tributaria NIF-IVA search.
- Enter the NIF-IVA: Enter the NIF in the format ES + 9-character NIF — for example,
ESB66254202. The ES country prefix is required. - Review the Result: A successful verification returns:
- Date of the verification
- Secure Verification Code (e.g.,
FSX32SJFVQA3TJ9P) — use this code to authenticate the result at agenciatributaria.gob.es
| Intra-community NIF Verification on Agencia Tributaria website |
| Successful NIF Verification |
NIF-IVA verification on EU VIES
For a legally binding confirmation before issuing a zero-rated intra-community invoice, also verify the NIF-IVA on the EU VIES system at ec.europa.eu/taxation_customs/vies/. A positive VIES result provides the VAT-exemption safe harbour under EU Directive 2006/112/EC. The Agencia Tributaria portal and VIES draw from the same ROI register, but VIES synchronisation can lag the national source by a few hours. Using both in sequence is best practice.
For companies not found in VIES or the Agencia Tributaria portal — typically domestic-only Spanish companies — verify their NIF through the Registro Mercantil Central (Commercial Register) at sede.registradores.org, which provides free searches by company name or NIF.
NIF format quick reference
| Entity type | Format | Example |
|---|---|---|
| Spanish company (S.A., S.L., etc.) | Letter (A–H, J, N–W) + 7 digits + 1 control char | B66254202 |
| Spanish individual (DNI) | 8 digits + 1 letter | 12345678Z |
| Foreign national resident (NIE used as NIF) | X, Y, or Z + 7 digits + 1 letter | X1234567L |
| Non-resident foreign legal entity | N + 7 digits + 1 control char | N1234567A |
| Foreign company permanent establishment | W + 7 digits + 1 control char | W1234567B |
| NIF-IVA (for EU transactions) | ES + NIF | ESB66254202 |
Frequently Asked Questions
My Spanish supplier's documents show a "CIF" number starting with B. Is this the same as their NIF?
Yes. The CIF (Código de Identificación Fiscal) was the former tax identifier for Spanish companies, replaced by the NIF in January 2008 under Royal Decree 1065/2007. The number itself did not change: a Spanish limited liability company (S.L.) whose CIF was B66254202 now has NIF B66254202. If you see a 9-character code starting with entity-type letters such as A (S.A. corporations) or B (S.L. companies) on older documents, it is the same identifier now called the NIF. Verify it on the Agencia Tributaria intra-community portal or EU VIES exactly as you would any NIF-IVA. [1]
I searched a Spanish supplier's NIF-IVA on EU VIES and got no result. Does this mean the company is fraudulent?
Not necessarily. Both EU VIES and the Agencia Tributaria intra-community portal only list companies registered in the Registro de Operadores Intracomunitarios (ROI) — businesses that have specifically applied for intra-EU trade authorisation by ticking box 582 on form 036. A legitimate Spanish company that trades only domestically will have a valid NIF in the AEAT census but will return "not found" in VIES. To verify a domestic-only Spanish company's NIF, check the Registro Mercantil at sede.registradores.org, which allows free searches by company name or NIF. [1]
Should I use EU VIES or the Agencia Tributaria portal before issuing a zero-rated intra-community invoice?
Use both. First query EU VIES (ec.europa.eu/taxation_customs/vies/) — a positive VIES result gives you the legal safe harbour for VAT exemption under EU Directive 2006/112/EC. If VIES returns "invalid" but you believe the company is legitimate, run a secondary check on the Agencia Tributaria intra-community portal, which can reflect data before VIES synchronises. Always document the VIES query date and consultation number before issuing a zero-rated invoice. [1]
A Spanish freelancer invoiced me using an NIE starting with X or Y as their NIF. Is this correct?
Yes. When a foreign national resident in Spain registers as self-employed (autónomo), their NIE (Número de Identificación de Extranjero) automatically becomes their NIF for all tax purposes. The NIE format is one letter (X, Y, or Z) followed by 7 digits and a checksum letter — for example, X1234567L. This is structurally different from a corporate NIF but equally valid on invoices. You cannot verify an autónomo's NIE-as-NIF through the VIES portal unless they have also registered for intra-community trade. For domestic invoice validation, request a copy of their Agencia Tributaria census registration confirmation (form 036 or 037 alta de autónomo). [1]
The NIF my Spanish counterparty provided starts with N or W — my validation library rejects it. Are these valid?
Yes, N-NIFs and W-NIFs are fully valid Spanish tax identifiers. The N-NIF is issued to non-resident foreign legal entities with tax obligations in Spain (e.g., a French holding company receiving Spanish-sourced royalties). The W-NIF is issued to permanent establishments of foreign companies in Spain (e.g., a UK company's registered branch in Madrid). Both follow the 9-character format: one letter + 7 digits + one control character. Most public NIF validators hard-code the accepted first-letter set for domestic companies (A–H) and incorrectly reject N and W prefixes. To verify these, use the Agencia Tributaria's VNifV2SOAP web service rather than a structural regex — VIES will not list them. [1]
Spain's SII system rejects our invoice because the customer's NIF is "not in the AEAT census." How do we fix this?
This is a documented SII scenario. When the invoice recipient is a foreign entity with no NIF in the AEAT census, do not use the standard NIF XML field. Instead, populate the IDOtro (IDOther) block with: the counterparty's country code (e.g., FR, DE), ID type code 04 for an EU VAT number or 06 for a passport or other document, and their tax ID. For a Spanish-registered entity whose NIF is not yet in the AEAT census, use country code ES, ID type 07 (not registered in AEAT), and the NIF number. This procedure is confirmed in the Agencia Tributaria's official SII FAQ, questions 25 and 44. [1]
The Agencia Tributaria SOAP API (VNifV2) requires an FNMT certificate we can't obtain as a foreign company. What are the alternatives?
The VNifV2SOAP endpoint requires a client-side FNMT-issued digital certificate that foreign companies without a Spanish legal entity generally cannot obtain. Practical alternatives: (1) Use a Spanish gestoría (tax agent) who holds an FNMT certificate and can perform batch NIF lookups; (2) Use EU VIES for companies registered for intra-community trade — no certificate required; (3) Use a licensed third-party API provider holding AEAT authorisation. Note: the older VNifV1SOAP endpoint referenced in community code samples has been superseded — only VNifV2 is actively maintained. [1]
I sell SaaS to Spanish customers under EU OSS. Do I need to verify their NIF, and does it affect whether I charge Spanish VAT?
For B2C digital sales to Spanish private individuals, you do not need to verify NIFs. Under the EU OSS regime you charge Spanish VAT (21% standard rate for digital services) on all sales to private individuals and remit via your OSS registration — no customer NIF check is required. The NIF question applies only when a customer claims to be a VAT-registered Spanish business (B2B): verify their NIF-IVA on EU VIES before issuing a zero-rated invoice. If VIES confirms the number, issue without VAT; if not confirmed, charge 21% Spanish VAT. [1]
How Lookuptax can help you in NIF validation?
Lookuptax NIF validation revolutionizes NIF number validation with its robust platform, empowering businesses to seamlessly verify NIF numbers across over 100 countries. Our cutting-edge technology ensures accurate and efficient validation, reducing errors and enhancing compliance.
