Spain NIF-IVA validator
How the NIF-IVA format works
- Format
- ES + 1 alphanumeric character + 7 digits + 1 alphanumeric character
- Example
- ESB64717838
Things to watch for
- The first and last characters can be letters or digits depending on entity type (DNI, NIE, or company CIF)
- Companies (CIF) use a Luhn-style check digit that can be shown as either a digit or a letter
^ES[0-9A-Z][0-9]{7}[0-9A-Z]$Spain’s VAT number, the NIF-IVA, has the most flexible shape in the EU: “ES”, then one character that can be a letter or a digit, then 7 digits, then another character that can again be a letter or a digit — for example ESX1234567X. That flexibility isn’t a loose spec; it reflects Spain running several taxpayer-ID systems (personal NIF/DNI, foreign-resident NIE, and company CIF) into a single VAT-number shape, where the leading and trailing characters signal entity type rather than following one fixed pattern.
That’s the detail worth remembering before assuming a Spanish VAT number is malformed: seeing a letter where you expected a digit, or vice versa, at either end isn’t necessarily wrong — it depends on whether the number belongs to an individual, a foreign resident, or a specific class of company. Rejecting a number purely because “it should be all digits” is a common but mistaken assumption with Spanish IDs.
Format check, in detail
This validator confirms the “ES” prefix, one alphanumeric character, 7 digits, and a final alphanumeric character, then dispatches to the matching check-digit algorithm based on the leading character: the mod-23 letter table for a personal DNI or foreign-resident NIE, and a Luhn-style calculation (accepting either a digit or its equivalent letter) for a company CIF — entirely in your browser, with no signup and nothing sent to a server.
What this can’t tell you
A checksum-valid NIF-IVA doesn’t confirm an active VAT registration. Confirm current status through the EU’s VIES lookup or Spain’s Agencia Tributaria before relying on it commercially.
Scope: NIF-IVA format and control-character validation for DNI, NIE, and CIF numbers — not registration status.
Content last reviewed 2026-07-07.
NIF-IVA FAQ
Why does a Spanish VAT number sometimes start with a letter and sometimes with a digit?
The leading character reflects entity type: companies typically get a letter indicating their legal form (for example a corporation versus a limited company), while Spanish individuals' NIF-IVA is built from their personal DNI, which is numeric at that position. Both are valid, just for different kinds of taxpayer.
What about the trailing character — is that also variable?
Yes, the final character can also be a letter or a digit depending on entity type and the control character calculated for that specific NIF or CIF. It isn't optional, but which kind of character it is depends on the taxpayer type.
Does this tool confirm the correct control letter or digit for a Spanish VAT number?
Yes, for the main entity types. Depending on the leading character it runs the matching algorithm — the mod-23 letter table for personal DNI/NIE numbers, or the Luhn-style CIF check (which accepts either a digit or a letter as the final character) for companies — so a pass confirms the control character is mathematically correct, not just present.