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.2.0

Published

[![NPM Version](https://img.shields.io/npm/v/validator-tax-id?style=flat-square)](https://www.npmjs.com/package/validator-tax-id) [![NPM Downloads](https://img.shields.io/npm/dm/validator-tax-id?style=flat-square)](https://www.npmjs.com/package/validator-

Readme

Tax ID Validator

NPM Version NPM Downloads License: MIT CI Tests

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

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)

Individual Validators (Recommended) ✨

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

import {
  // Spain
  validateDNI,
  validateNIE,
  validateCIF,
  // France
  validateSIREN,
  validateSIRET,
  validateNIR,
  // Portugal
  validateNIF,
} 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

Country Auto-detect

If you don't know the specific document type:

import { validateES, validateFR, validatePT } 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

API Reference

validateIdentification(country, value)

  • country: CountryCode ('es' | 'pt' | 'fr') - The ISO code of the country.
  • value: string | any - 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).

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 |

Changelog

All notable changes to this project will be documented in this file.

[1.2.0] - 2026-01-19

Added 🚀

  • Individual Validators: New exported functions for direct validation:
    • Spain: validateDNI, validateNIE, validateCIF, validateES
    • France: validateSIREN, validateSIRET, validateNIR, validateFR
    • Portugal: validateNIF, validatePT
  • Better tree-shaking support with individual exports
  • Country auto-detect validators (validateES, validateFR, validatePT)

[1.1.3] - 2026-01-18

Added 🚀

  • France (FR) added validation for NIR document and fix SIREN-SIRET algorithm
  • Spain (ES) added validation for CIF document.
  • Portugal (PT) added validation on prefix in NIF document

[1.1.0] - 2026-01-17

Added 🚀

  • France (FR) support added.
  • Validation for SIREN (9 digits) and SIRET (14 digits) using Luhn algorithm.

[1.0.0] - 2026-01-17

Added

  • Initial release.
  • Spain (ES) support: DNI and NIE validation (Modulo 23).
  • Portugal (PT) support: NIF validation (Modulo 11).
  • Core logic and TypeScript types.

License

MIT