Spanish VAT Number Validator
Validate the format of a Spanish VAT number (NIF/CIF: ES + 9 characters). Check the tax registration of Spanish companies and freelancers before invoicing.
Result
—
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 23mapped to the stringTRWAGMYFPDXBNJZSQVHLCKE. - NIE for foreigners: leading
X,YorZ(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— cooperativaG— asociación/fundación;J— sociedad civilN— 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
UK VAT Number Validator
Validate the format of a UK VAT number (GB + 9 digits). Check the tax registration of British companies before invoicing or trading.
EU VAT (per country) Validator
Validate EU VAT format per country (DE, FR, IT, ES, PT, NL, BE, AT…).
Italian VAT Number Validator
Validate the format of an Italian VAT number (Partita IVA: IT + 11 digits). Check the tax registration of Italian companies before invoicing or trading.
German VAT Number Validator
Validate the format of a German VAT number (USt-IdNr.: DE + 9 digits). Check the tax registration of German companies before invoicing or trading.
French VAT Number Validator
Validate the format of a French VAT number (TVA: FR + 11 characters). Check the tax registration of French companies before invoicing or trading.
Portuguese NIF/VAT Validator
Validate the Portuguese NIF/NIPC tax number (9 digits) using the official check digit. Verify the tax ID of individuals and companies in Portugal.