A Spanish VAT number (Número de Identificación Fiscal a efectos del IVA, or NIF-IVA) is the ES prefix followed by a 9-character tax identifier. Unlike many EU countries, Spain reuses its national identifiers — the DNI for residents, the NIE for foreigners, and the CIF for legal entities — as the body of the VAT number. This validator detects which structure you have entered and recomputes the official control character so you can catch typos before submitting an invoice or a VIES lookup.
How it works
There are three valid structures behind the ES prefix:
- DNI (individuals): 8 digits plus a control letter. The letter is
TRWAGMYFPDXBNJZSQVHLCKEindexed bynumber mod 23. - NIE (foreign residents): a leading
X,YorZ, 7 digits, and a control letter. MapXto0,Yto1,Zto2, then apply the same mod-23 rule. - CIF (entities): an entity-type letter, 7 digits, and a control character. Digits in odd positions are doubled and digit-summed, even positions are added directly; the control is
(10 - units) mod 10, expressed as a digit or as a letter fromJABCDEFGHIdepending on the entity type.
Example
For the DNI body 12345678Z, compute 12345678 mod 23 = 14, and the 15th character (0-indexed 14) of TRWAGMYFPDXBNJZSQVHLCKE is Z. The control letter matches, so ES12345678Z is internally valid.
Notes
A valid check character means the identifier is well-formed, not that the entity is currently VAT-registered. For real-time confirmation in intra-EU transactions, query the official EU VIES system. This tool performs no network lookup — everything is computed in your browser.