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

validator-tax-id

v1.3.0

Published

A lightweight, zero-dependency, and universal TypeScript library to validate Tax IDs (Identification Numbers)

Downloads

42

Readme

Tax ID Validator

A lightweight, zero-dependency, and universal TypeScript library to validate Tax IDs (Identification Numbers)

It uses precise mathematical algorithms to verify the integrity of the document number and follow guides of the country governments

NPM Version NPM Downloads License: MIT CI Tests Donate

Supported Countries

| Country | Code | Documents Supported | Algorithm | | ----------- | ---- | ------------------------------ | ------------------ | | 🇪🇸 Spain | es | DNI, NIE, CIF | Module 23 | | 🇵🇹 Portugal | pt | NIF (Personal) | Module 11 | | 🇫🇷 France | fr | SIREN, SIRET, NIR | Luhn + Mod.97 | | 🇩🇪 Germany | de | SteuerIdNr, VAT Number, W-IdNr | ISO 7064 Mod 10,11 |

Features

  • 🚀 Lightweight: Zero external dependencies.
  • 🔒 Type-Safe: Written in TypeScript with full type definitions.
  • 🌍 Universal: Works in Node.js, React, Vue, Next.js, and Browsers (Legacy Script Tag).
  • Tree-shakeable: Only import what you need (if using advanced exports).

Installation

npm install validator-tax-id
# or
yarn add validator-tax-id
# or
pnpm add validator-tax-id

Usage

Basic Usage

The main function validateIdentification takes two arguments: the country code (ISO 3166-1 alpha-2) and the value to validate.

import { validateIdentification } from "validator-tax-id";

// 🇪🇸 Spain (ES)
validateIdentification("es", "12345678Z"); // true (DNI)
validateIdentification("es", "X1234567L"); // true (NIE)
validateIdentification("es", "A58818501"); // true (CIF)

// 🇵🇹 Portugal (PT)
validateIdentification("pt", "232013969"); // true (NIF)

// 🇫🇷 France (FR)
validateIdentification("fr", "443061841"); // true (SIREN)

// 🇩🇪 Germany (DE)
validateIdentification("de", "86095742719"); // true (SteuerIdNr)
validateIdentification("de", "DE136695976"); // true (VAT Number)

Individual Validators (Recommended) ✨

For better tree-shaking and direct access, use individual validators:

import {
  // Spain
  validateDNI,
  validateNIE,
  validateCIF,
  // France
  validateSIREN,
  validateSIRET,
  validateNIR,
  // Portugal
  validateNIF,
  // Germany
  validateSteuerIdNr,
  validateVatNumber,
  validateWidnr,
} from "validator-tax-id";

// 🇪🇸 Spain - Direct validation
validateDNI("12345678Z"); // true
validateNIE("X1234567L"); // true
validateCIF("A58818501"); // true

// 🇫🇷 France - Direct validation
validateSIREN("443061841"); // true
validateSIRET("44306184100047"); // true
validateNIR("188057512301180"); // true

// 🇵🇹 Portugal - Direct validation
validateNIF("123456789"); // true

// 🇩🇪 Germany - Direct validation
validateSteuerIdNr("86095742719"); // true
validateVatNumber("DE136695976"); // true
validateWidnr("136695976"); // true

Country Auto-detect

If you don't know the specific document type:

import {
  validateES,
  validateFR,
  validatePT,
  validateDE,
} from "validator-tax-id";

validateES("12345678Z"); // true (auto-detects DNI)
validateES("A58818501"); // true (auto-detects CIF)
validateFR("443061841"); // true (auto-detects SIREN)
validatePT("123456789"); // true
validateDE("86095742719"); // true (auto-detects SteuerIdNr)
validateDE("DE136695976"); // true (auto-detects VAT Number)

API Reference

validateIdentification(country, value)

  • country: CountryCode ('es' | 'pt' | 'fr' | 'de') - The ISO code of the country.
  • value: string - The document string to validate.
  • Returns: boolean (true if valid, false otherwise).

Note: The validator sanitizes the input automatically (removes spaces, hyphens, and is case-insensitive).

Support

If this library helped you, consider buying me a coffee ☕

Donate

License

MIT