1001Ferramentas
🇪🇸Validators

VAT Espanhol

Valida formato NIF/CIF espanhol (ESXXXXXXXXX).

Resultado

Spanish VAT number (NIF-IVA / NIF / CIF): a letter that tells you what kind of taxpayer it is

Spain's VAT number is the NIF-IVA: the prefix ES followed by the 9-character NIF (Número de Identificación Fiscal). Unlike purely numeric VAT IDs, the Spanish NIF can start or end with a letter, and that letter encodes the taxpayer type. The general shape is character + 7 digits + character, where the first and/or last position may be a letter or a control digit.

There are three broad families:

  • DNI/NIF for residents: 8 digits + 1 control letter, where the letter comes from número mod 23 mapped to the string TRWAGMYFPDXBNJZSQVHLCKE.
  • NIE for foreigners: leading X, Y or Z (converted to 0/1/2) + 7 digits + control letter, same mod-23 table.
  • CIF for legal entities (the old company code, now folded into NIF): leading organization letter (A = S.A., B = S.L., G = associations, etc.) + 7 digits + a control character that is a digit or a letter depending on the entity type.

What the leading letter means (CIF)

  • A — Sociedad Anónima (S.A.)
  • B — Sociedad Limitada (S.L.)
  • E — comunidad de bienes; F — cooperativa
  • G — asociación/fundación; J — sociedad civil
  • N — entidad extranjera; P/Q/S — public bodies

Common pitfalls

  • Letter vs digit control: for some CIF organization types the control character is a letter (A–J), for others a digit — using the wrong one fails validation.
  • Case sensitivity: NIF letters are uppercase; normalize before checking.
  • Format ≠ registration: a structurally valid NIF still needs VIES (or the AEAT) to confirm it's an active VAT registration.

FAQ

Is the CIF still used? The CIF was officially merged into the NIF in 2008, but the term is still widely used for company tax IDs and the format lives on.

How is the DNI control letter computed? Take the 8-digit number mod 23 and look it up in TRWAGMYFPDXBNJZSQVHLCKE.

What's the difference between NIF and NIE? NIF is for Spanish nationals and entities; NIE is the foreigner's identification number (starts with X/Y/Z).

Related Tools