npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eu-tax-id-validator

v1.0.0

Published

Validate European tax IDs (VAT numbers, NIF, CIF) with format checks and checksum verification. Supports 30 countries: 27 EU + UK, Norway, Switzerland. Zero dependencies.

Readme

eu-tax-id-validator

Validate European tax IDs (VAT numbers, NIF, CIF) with format checks and checksum verification. Zero dependencies, < 5KB minified.

Supports 30 countries: 27 EU member states + United Kingdom, Norway, and Switzerland.

Install

npm install eu-tax-id-validator

Quick Start

import { validateTaxId, detectCountry, formatVatNumber } from 'eu-tax-id-validator';

// Validate with checksum
validateTaxId('PT502011378');
// { valid: true, country: 'PT', normalized: 'PT502011378', checksum_verified: true }

// Auto-detect country
detectCountry('502011378');
// 'PT'

// Format for display
formatVatNumber('PT502011378');
// 'PT 502 011 378'

API

validateTaxId(raw: string): ValidationResult

Validates a tax ID / VAT number. Cleans input (removes spaces, dashes, dots), auto-detects country, and runs format + checksum validation.

interface ValidationResult {
  valid: boolean;
  country: string | null;
  normalized: string;        // Cleaned, uppercase, with country prefix
  checksum_verified: boolean; // true if checksum algorithm verified
  error?: string;
}

detectCountry(taxId: string): string | null

Detects country from a tax ID. Tries 2-letter prefix first, then format-based detection.

formatVatNumber(taxId: string, country?: string): string

Formats a tax ID with country-specific grouping for display.

| Country | Input | Output | |---------|-------|--------| | PT | PT502011378 | PT 502 011 378 | | DK | DK10150817 | DK 10 15 08 17 | | GB | GB123456789 | GB 123 4567 89 | | DE | DE123456789 | DE 123 456 789 | | PL | PL7740001454 | PL 774-000-14-54 | | FI | FI01234562 | FI 0123456-2 | | CH | CH105835786 | CH 105.835.786 |

isEUMember(countryCode: string): boolean

Returns true if the country is an EU member state.

COUNTRIES

Object with metadata for all 30 supported countries:

COUNTRIES['PT']
// { code: 'PT', name: 'Portugal', local_name: 'Portugal',
//   tax_id_name: 'NIF', eu_member: true, has_checksum: true,
//   format_description: '9 digits with Modulo 11' }

Supported Countries

Full checksum validation (7 countries)

| Country | Tax ID | Algorithm | |---------|--------|-----------| | PT Portugal | NIF | Modulo 11 | | DK Denmark | CVR | Modulo 11 | | NO Norway | Org.nr | Modulo 11 | | FI Finland | Y-tunnus | Modulo 11 | | PL Poland | NIP | Weighted checksum | | CZ Czech Republic | IČO | Modulo 11 | | CH Switzerland | UID | Modulo 11 |

Format validation (23 countries)

AT, BE, BG, CY, DE, EE, EL (Greece), ES, FR, GB, HR, HU, IE, IT, LT, LU, LV, MT, NL, RO, SE, SI, SK

Features

  • Zero dependencies — pure TypeScript, no runtime deps
  • Dual format — ESM and CommonJS
  • Tree-shakeable — import only what you need
  • Tiny — < 5KB minified
  • Type-safe — full TypeScript types exported
  • 30 countries — 27 EU + UK, Norway, Switzerland
  • Checksum verification — Modulo 11 and weighted checksums for 7 countries
  • Input cleaning — handles spaces, dashes, dots, lowercase

Going Beyond Validation

Need live company data — name, address, legal form, directors, VAT status?

VeriCorp API enriches tax IDs with real-time data from official registries across Europe. 8 countries with full enrichment, 27 with VAT validation.

// Local validation (this package)
validateTaxId('PT502011378');
// { valid: true, country: 'PT', checksum_verified: true }

// Live enrichment (VeriCorp API)
// → name: "Nexperience Lda", status: "active", address: "...", legal_form: "Lda", ...

Get your free API key →

License

MIT