Guide8 min readAlberto García

UK VAT Validation API: Post-Brexit Tax ID Checks for Developers

Since Brexit, UK VAT numbers are no longer part of VIES and must be validated via HMRC independently. This guide covers the GB format, what changed, and how to validate correctly in Node.js and Python.

ukvatapiguidebrexit

Before Brexit, UK VAT numbers were part of the EU VIES system and could be validated with the same SOAP call as any other EU country. Since 1 January 2021, UK VAT is administered by HMRC independently, and UK numbers no longer appear in VIES. If your code queries VIES for a `GB` number, it will return `format_invalid` or `service_unavailable`. You need a validation API that routes `GB` numbers to HMRC separately.

UK VAT Number Format

UK VAT numbers follow the format `GB` followed by 9 digits. The 9-digit portion is structured as a 7-digit registration number followed by a 2-digit suffix. Branch traders also have a 3-digit branch identifier appended, giving 12 digits total. For most validation purposes, you only need the 9-digit version.

FormatExampleNotes
GB + 9 digitsGB123456789Standard VAT number — most common
GB + 12 digitsGB123456789012Branch trader — 3-digit branch suffix
GBGD + 3 digitsGBGD001Government departments
GBHA + 3 digitsGBHA500Health authorities
XI + 9 digitsXI123456789Northern Ireland — trade in goods with EU

The XI Prefix: Northern Ireland Special Case

Northern Ireland occupies a unique position post-Brexit: for trade in goods (not services), Northern Ireland businesses follow EU VAT rules and can be validated via a special `XI` prefix in VIES. This means a Northern Ireland company may have both a `GB` VAT number (for UK domestic trade and services) and an `XI` number (for intra-EU goods trade). When validating a Northern Ireland supplier or customer for EU goods transactions, use the `XI` number.

Validating UK VAT Numbers via TaxID API

The TaxID API routes `GB` numbers to HMRC's VAT API and `XI` numbers to VIES automatically. The request format is identical to EU countries.

typescriptlib/validate-uk-vat.ts
async function validateUkVat(vatNumber: string) {
  // GB123456789 → GET /validate/GB/GB123456789
  // XI123456789 → GET /validate/XI/XI123456789
  const normalised = vatNumber.replace(/[\s\-]/g, '').toUpperCase();
  const prefix = normalised.startsWith('XI') ? 'XI' : 'GB';

  const res = await fetch(
    `https://taxid.dev/api/v1/validate/${prefix}/${normalised}`,
    { headers: { Authorization: `Bearer ${process.env.TAXID_API_KEY}` } }
  );

  return res.json();
}

// Usage:
const result = await validateUkVat('GB123456789');
// { valid: true, status: 'active', company_name: 'Example Ltd', ... }
pythonvalidate_uk_vat.py
import os, requests

def validate_uk_vat(vat_number: str) -> dict:
    normalised = vat_number.replace(' ', '').replace('-', '').upper()
    prefix = 'XI' if normalised.startswith('XI') else 'GB'

    resp = requests.get(
        f'https://taxid.dev/api/v1/validate/{prefix}/{normalised}',
        headers={'Authorization': f'Bearer {os.environ["TAXID_API_KEY"]}'},
        timeout=5,
    )
    resp.raise_for_status()
    return resp.json()

What Changed After Brexit: VIES vs HMRC

AspectPre-Brexit (VIES)Post-Brexit (HMRC)
PrefixGB in VIESGB via HMRC API, XI via VIES
Legal frameworkEU VAT DirectiveUK VAT Act 1994
Format checkEU VIES validationHMRC format rules
Company name returnedYesYes
Address returnedYesYes
AvailabilitySubject to VIES outagesHMRC uptime (generally more stable)

Making Tax Digital Compliance

HMRC's Making Tax Digital (MTD) for VAT programme requires businesses to keep digital records and submit VAT returns via compatible software. For B2B sellers, this means the VAT number used to justify a zero-rated supply must be recorded digitally in your VAT account. Storing the TaxID `request_id` alongside the transaction is best practice — it provides a digitally-traceable audit reference showing that validation occurred via an API call at a specific time.

Note

UK zero-rating for B2B supplies requires proof that the customer is a UK or EU VAT-registered business. For UK-to-UK supplies, the relevant rule is UK VAT Act 1994 s.30 and VAT Notice 700. For UK-to-EU supplies (goods), the export zero-rating rules under UK VAT Notice 703 apply.

Start validating EU VAT numbers

Free plan — 100 validations/month. No credit card required.

AG
Alberto García

Founder, TaxID

Building EU VAT validation tools for developers. Obsessed with compliance automation and developer experience.