Spain VAT number: format and validation
Format
ES followed by 9 characters: a letter or digit, then 7 digits, then a letter or digit. The local term is Numero de Identificacion Fiscal (IVA: Impuesto sobre el Valor Anadido) (NIF-IVA, Spanish).
Pattern: /^[A-Z0-9]\d{7}[A-Z0-9]$/
- Company NIFs open with a legal-form letter (A for sociedad anonima, B for sociedad limitada) and close with a control character
- A valid Spanish NIF returns invalid in VIES unless the business is enrolled in the ROI (Registro de Operadores Intracomunitarios)
- VIES returns no name and address for Spanish numbers (Spain withholds them), so a valid check gives no company data
Example of a registered number: ESA28015865
Check digit
Spain VAT numbers carry a check digit (Control character): For legal entities the final character is a check digit or letter derived from the seven middle digits under Spain's NIF composition rules (Orden EHA/451/2008).
Check a Spain VAT number
Validated live against the AEAT (Agencia Estatal de Administracion Tributaria) (official register).
Enter a VAT number to see the live API response
Validate via API
The same validation as an API call, with the example number above:
curl "https://api.avatcado.com/v1/validate?vat_number=ESA28015865" \
-H "Authorization: Bearer avat_live_your_api_key"import Avatcado from "@avatcado/node";
const avatcado = new Avatcado("avat_live_your_api_key");
const { data, error } = await avatcado.vat.validate({
vatNumber: "ESA28015865",
});
if (data?.data.valid) {
console.log(`Registered: ${data.data.company?.name}`);
}Free tier includes 500 validations per month. Get an API key or read the API documentation.
Frequently asked questions
Why does a real Spanish VAT number fail VIES validation?
Spain only feeds VIES with businesses enrolled in the ROI. A domestic-only company has a perfectly valid NIF but no NIF-IVA, so VIES reports it invalid; that means 'not registered for intra-EU trade', not 'fake number'.
Is a CIF different from a NIF?
No longer: the separate CIF for companies was folded into the NIF by Orden EHA/451/2008, though the old term is still common. The company format (letter + 7 digits + control character) survived the rename.
Related guides
- How to Validate EU VAT Numbers Programmatically
- VIES API Guide: EU VAT Validation Explained
- EU VAT Reverse Charge: What Developers Need to Know
VAT rate in Spain
The standard VAT rate in Spain is 21%. Reduced rates: 10%, 4%. See all Spain VAT rates.
Sources
- ROI, VIES and NIF-IVA Agencia Tributaria, accessed August 13, 2026
- Orden EHA/451/2008 (NIF composition) Boletin Oficial del Estado, accessed August 13, 2026
- VIES VAT validation European Commission, accessed August 13, 2026