Spanish NIF validator for CIF, DNI and NIE

Check whether a Spanish tax ID is correct and, if it belongs to a company, who it is and whether it is still active. For a DNI or NIE we verify the letter or work it out. Free, no sign-up.

Try:
  • DNI and NIE: unlimited, checked in your browser
  • Companies: 5 free lookups a day
  • +4.7 M Spanish companies

Guide

The four types of Spanish tax ID

The NIF identifies any person or entity before the Spanish Tax Agency. Depending on the holder it takes one of these forms. All of them end in a control character, used to catch typing mistakes.

TypeWho has itFormatExample
DNISpanish citizens8 digits and a letter12345678Z
NIEForeign residentsX, Y or Z, 7 digits and a letterX1234567L
Company NIF (CIF)Companies and other entitiesA letter, 7 digits and a control digit or letterA46103834
Special NIFMinors without DNI (K), people without DNI or NIE (L, M)K, L or M, 7 digits and a letterK1234567L

Company tax ID

What the first letter of a CIF means

The first letter of a company tax ID shows its legal form. Then come 7 digits and a control character, which is a digit for A, B, E and H, a letter for N, P, Q, R, S and W, and either for the rest.

  • APublic limited company (SA)
  • BPrivate limited company (SL)
  • CGeneral partnership
  • DLimited partnership
  • EJoint ownership (comunidad de bienes)
  • FCooperative
  • GAssociation or foundation
  • HOwners’ association
  • JCivil partnership
  • NForeign entity
  • PLocal authority
  • QPublic body
  • RReligious entity
  • SGovernment body
  • UTemporary business association (UTE)
  • VOther types
  • WPermanent establishment of a non-resident

DNI letter table (remainder → letter)

T0
R1
W2
A3
G4
M5
Y6
F7
P8
D9
X10
B11
N12
J13
Z14
S15
Q16
V17
H18
L19
C20
K21
E22

Example

12345678 ÷ 23 = 536,768, remainder 14
Remainder 14 → Z
Full DNI: 12345678Z

Beyond the format

Checking that a tax ID exists and who it belongs to

Company CIF

It is public. With this validator or the Spanish company search you see the legal name, whether it is still active and its latest entries in the BORME.

DNI or NIE

They are personal data: only the letter can be checked. Confirming that an ID exists and who holds it is up to the Spanish Tax Agency (AEAT).

EU VAT number

To invoice a Spanish business without VAT within the EU, its VAT number (ES + NIF) must be registered in VIES. The API checks it in the same call.

For businesses

Validate all your Spanish customers in one call

With the API you send up to 1,000 tax IDs of customers or suppliers per request and get, for each one, whether it exists, its legal name, its status and whether the name you have on file matches. You only pay for the companies found: badly written IDs and individuals are free.

Try 100 free calls
{
  "items": [
    { "cif": "A46103834", "name": "MERCADONA SA" },
    { "cif": "B12345678", "name": "MY CUSTOMER SL" }
  ],
  "vat": false
}

→ exists, legal_name, status_code, name_check, invoice_hint
For onboarding, KYB and e-invoicing. Read the docs

FAQ

Frequently asked questions about the Spanish NIF

How do I know if a Spanish NIF is valid?

Type it in the validator on this page. For a DNI or NIE we check that the letter matches the number. For a company tax ID (CIF) we check the control character and look the company up, so you can see who it belongs to and whether it is still active.

What is the difference between NIF, CIF, DNI and NIE?

NIF (Número de Identificación Fiscal) is the Spanish tax ID of any person or entity. For a Spanish citizen it is their DNI with its letter; for a foreign resident, their NIE; for a company, what used to be called the CIF. Since 2008 it is officially an NIF, but most people still call it CIF.

How is the DNI letter calculated?

Divide the DNI number by 23 and take the remainder (0 to 22). Each remainder maps to a letter in the table TRWAGMYFPDXBNJZSQVHLCKE: 0 is T, 1 is R, 2 is W, and so on. For example, 12345678 divided by 23 leaves 14, so the letter is Z.

How do I check an NIE number?

An NIE starts with X, Y or Z, followed by 7 digits and a letter. Replace X with 0, Y with 1 or Z with 2, and calculate the letter as for a DNI. The validator does it for you, in your browser.

Is a Spanish NIF the same as the EU VAT number?

Almost. The Spanish VAT number for intra-EU trade is ES followed by the NIF (for example ESA46103834). A valid NIF is not automatically registered for intra-EU operations: that is checked in VIES, the European Commission system. The API checks VIES in the same call (vat=true).

Can I find out who a DNI or NIE belongs to?

No. DNI and NIE numbers are personal data and are not published. We can only check that the letter is correct. Company tax IDs are public: they appear in the BORME, on invoices and in the legal notice of their websites, which is why we can tell you which company a CIF belongs to.

Can I validate many Spanish tax IDs at once?

Yes, with the API: send up to 1,000 tax IDs of customers or suppliers in one call and get, for each one, whether it exists, its legal name and its status. You only pay for the companies found.

Validate Spanish tax IDs from your form, ERP or spreadsheet

One API call per tax ID tells you whether the company exists, its legal name, its status and, if you ask, whether its VAT number is in VIES. 100 free calls, no card required.

Get free API key
🤖
Asistente IA En línea
¡Hola! Soy el asistente de APIEmpresas. ¿En qué puedo ayudarte hoy?