How to Validate EU VAT Numbers Programmatically

EU VAT validation is a required compliance step for any business selling B2B across EU borders. This guide explains what it is, why it matters, and how to automate it.

What is EU VAT validation?

Every EU business registered for VAT is assigned a unique VAT identification number — for example DE134214316 for a German company or IE6388047V for an Irish one. The number always starts with the two-letter ISO country code followed by a country-specific sequence of digits and letters.

Validating a VAT number means confirming two things: first, that the number is correctly formatted for its country; second, and more importantly, that it is currently registered and active in the VIES database. A number can be correctly formatted but belong to a company that has since deregistered — which is why format-only checks are insufficient for compliance purposes.

Why does it matter for invoicing and reverse charge?

When a VAT-registered business in one EU member state sells services or goods to a VAT-registered buyer in another EU member state, the transaction is typically subject to the reverse charge mechanism. Under reverse charge, the supplier issues the invoice without VAT and the buyer accounts for the tax in their own country. The supplier saves the cash-flow cost of collecting and remitting foreign VAT; the buyer self-assesses at their local rate.

The reverse charge can only be applied when the buyer has a valid, active VAT number at the time the invoice is issued. If you apply the zero rate without confirming the buyer's VAT status and that number turns out to be invalid, the tax authority in your country can hold you liable for the full VAT amount. For high-volume SaaS or service businesses, the exposure can be substantial.

Best practice is to validate the VAT number at the point of checkout or contract creation and then re-validate periodically for long-running subscriptions, since a customer's VAT registration can lapse.

How VIES works

VIES (VAT Information Exchange System) is the European Commission's official database for cross-border VAT number verification. Each EU member state maintains its own VAT registry and exposes it through a national node connected to VIES. When you query VIES for a number like IE6388047V, VIES routes the request to Ireland's Revenue authority in real time and returns the current registration status along with the company name and address (where the national system permits it — Germany, for example, does not return company details via VIES).

VIES availability depends on each national node being online. Individual country nodes do go down for maintenance, which is why production integrations should handle 503 errors gracefully and retry. The vatnode API handles this automatically, including a fallback to the German BZSt eVatR service for DE numbers when the German VIES node is rate-limited or unreachable. Note that the BZSt fallback returns valid/invalid status only — company name and address are not available from this source.

Automate VAT validation with the vatnode API

The vatnode API wraps VIES in a reliable REST interface with response caching, automatic retries, and structured JSON responses. A single GET request returns everything you need to make an invoicing decision.

cURL
curl https://api.vatnode.dev/v1/vat/IE6388047V \
  -H "Authorization: Bearer $VATNODE_API_KEY"
JavaScript / TypeScript
// Validate a buyer's VAT number before issuing a B2B invoice
async function validateBuyerVat(vatId: string) {
  const response = await fetch(
    `https://api.vatnode.dev/v1/vat/${encodeURIComponent(vatId)}`,
    {
      headers: {
        Authorization: `Bearer ${process.env.VATNODE_API_KEY}`,
      },
    }
  )

  if (!response.ok) {
    const err = await response.json()
    throw new Error(err.error?.message ?? `HTTP ${response.status}`)
  }

  const result = await response.json()

  return {
    valid: result.valid,
    companyName: result.companyName,
    countryCode: result.countryCode,
    // Apply reverse charge only when valid and buyer is in a different EU member state
    applyReverseCharge: result.valid,
  }
}

// Usage in a checkout flow
try {
  const buyer = await validateBuyerVat('IE6388047V')
  if (!buyer.valid) {
    return { error: 'VAT number is not active. Please check and try again.' }
  }
  console.log(`Verified: ${buyer.companyName} — reverse charge applies`)
} catch (error) {
  // VIES may be temporarily unavailable — handle gracefully
  console.error('VAT check failed:', error.message)
}

The response includes the company name and address (where available from VIES), the current standard and reduced VAT rates for the buyer's country, and a unique checkId you can store in your invoice record as an audit trail.

VAT number format by country

All EU VAT numbers include the two-letter country code as a prefix. The total length and character set varies by country:

CountryFormatExample
GermanyDE + 9 digitsDE134214316
FranceFR + 2 chars + 9 digitsFR12345678901
NetherlandsNL + 9 digits + B + 2 digitsNL123456789B01
SpainES + 1 char + 7 digits + 1 charESA12345678
IrelandIE + 7 digits + 1–2 lettersIE6388047V
PolandPL + 10 digitsPL1234567890

The vatnode API normalizes inputs automatically — whitespace, dashes, and mixed case are all accepted. See the full format reference for all 27 member states.

Ready to add VAT validation to your app?

Get a free API key and make your first call in under 5 minutes. No credit card required to start.