🚀. Socket Launch Week Day 2:Introducing Manifest Alerts.Learn more
Sign In

@stll/stdnum

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stll/stdnum

Validate, compact, and format standard identifiers for Node.js and Bun. Pure TypeScript, zero dependencies, tree-shakeable per identifier.

latest
Source
npmnpm
Version
2.1.1
Version published
Weekly downloads
3.8K
41.62%
Maintainers
1
Weekly downloads
 
Created
Source

stella

@stll/stdnum

Validate, compact, and format standard identifiers for Node.js and Bun. Pure TypeScript, zero dependencies, tree-shakeable per identifier.

This package covers 7 international identifiers and 96 countries through per-module entry points.

Install

npm install @stll/stdnum
# or
bun add @stll/stdnum

Usage

import { cz } from "@stll/stdnum";

cz.ico.validate("25596641");
// { valid: true, compact: "25596641" }

cz.ico.validate("12345678");
// { valid: false, error: { code: "INVALID_CHECKSUM", ... } }

cz.rc.format("7103192745");
// "710319/2745"

Tree-shaking

Import only what you need:

import ico from "@stll/stdnum/cz/ico";
import iban from "@stll/stdnum/iban";

ico.validate("25596641");
iban.validate("CZ65 0800 0000 1920 0014 5399");

Oracle Validation

The repo ships two oracle modes:

  • bun run oracle Runs the strict gate. It keeps only high-confidence cross-checks that are stable enough for CI.
  • bun run oracle:survey Runs the broader ecosystem survey. It includes noisier third-party validators and mutation probes to surface drift without treating every disagreement as a release blocker.

Both commands accept ORACLE_SAMPLES=<n> to trade off runtime against coverage.

Supported Identifiers

International

IdentifierModuleType
BIC (ISO 9362)biccompany
Credit Card (Luhn)creditcardany
Crypto Walletcrypto/walletany
IBANibanany
ISIN (ISO 6166)isinany
LEIleicompany
Luhnluhnany
EU VATeu/vatcompany

Countries

96 countries supported (click to expand)
CountryModuleIdentifier
AD Andorraad/nrtNRT
AE United Arab Emiratesae/eidEID
AI Anguillaai/tinTIN
AL Albaniaal/niptNIPT
AM Armeniaam/tinTIN
AR Argentinaar/cbuCBU
ar/cuitCUIT
ar/dniDNI
AT Austriaat/businessidFN
at/tinTIN
at/uidUID
at/vnrVNR
AU Australiaau/abnABN
au/acnACN
au/tfnTFN
AZ Azerbaijanaz/voenVÖEN
BA Bosnia and Herzegovinaba/jmbgJMBG
BD Bangladeshbd/nidNID
BE Belgiumbe/bisBIS
be/nnNN
be/vatBTW
BG Bulgariabg/egnЕГН
bg/pnfЛНЧ
bg/vatИН по ДДС
BH Bahrainbh/cprCPR
BR Brazilbr/cnpjCNPJ
br/cpfCPF
BY Belarusby/unpУНП
BZ Belizebz/tinTIN
CA Canadaca/bnBN
ca/sinSIN
CH Switzerlandch/ssnAHV
ch/uidUID
ch/vatMWST
CL Chilecl/rutRUT
CN Chinacn/ricRIC
cn/usccUSCC
CO Colombiaco/nitNIT
CR Costa Ricacr/cpfCPF
CU Cubacu/niNI
CY Cypruscy/vatΦΠΑ
CZ Czech Republiccz/dicDIČ
cz/icoIČO
cz/rc
DE Germanyde/handelsregHReg
de/idnrIdNr
de/stnrStNr
de/svnrSVNR
de/vatUSt-IdNr.
DK Denmarkdk/cprCPR
dk/cvrCVR
dk/vatCVR
DO Dominican Republicdo/rncRNC
EC Ecuadorec/rucRUC
EE Estoniaee/ikIK
ee/registrikoodRegistrikood
ee/vatKMKR
EG Egypteg/tnTN
ES Spaines/cifCIF
es/dniDNI
es/nieNIE
es/nssNSS
es/vatNIF
FI Finlandfi/hetuHETU
fi/vatALV nro
fi/ytunnusY-tunnus
FR Francefr/nifNIF
fr/nirNIR
fr/sirenSIREN
fr/siretSIRET
fr/tvaTVA
GB United Kingdomgb/ninoNINO
gb/nhsNHS
gb/sedolSEDOL
gb/utrUTR
gb/vatVAT
GE Georgiage/pinPIN
GH Ghanagh/tinTIN
GR Greecegr/amkaΑΜΚΑ
gr/vatΑΦΜ
GT Guatemalagt/nitNIT
HK Hong Konghk/hkidHKID
HR Croatiahr/vatOIB
HU Hungaryhu/vatANUM
ID Indonesiaid/npwpNPWP
IE Irelandie/ppsPPS
ie/vatVAT
IL Israelil/idnrת.ז.
IN Indiain/aadhaarAadhaar
in/gstinGSTIN
in/panPAN
IQ Iraqiq/nidNID
IR Iranir/nidNID
IS Icelandis/kennitalakt.
is/vskVSK
IT Italyit/codicefiscaleCF
it/ivaP.IVA
JP Japanjp/cnCN
jp/mynumberMy Number
KR South Koreakr/brnBRN
kr/rrnRRN
KW Kuwaitkw/civilCivil ID
KZ Kazakhstankz/iinIIN
LI Liechtensteinli/peidPEID
LK Sri Lankalk/nicNIC
LT Lithuanialt/asmensAK
lt/vatPVM kodas
LU Luxembourglu/vatTVA
LV Latvialv/vatPVN
MA Moroccoma/iceICE
MC Monacomc/tvaTVA
MD Moldovamd/idnoIDNO
ME Montenegrome/pibPIB
MK North Macedoniamk/edbEDB
MT Maltamt/vatVAT
MU Mauritiusmu/brnBRN
MX Mexicomx/clabeCLABE
mx/curpCURP
mx/rfcRFC
MY Malaysiamy/nricNRIC
NG Nigeriang/ninNIN
NI Nicaraguani/rucRUC
NL Netherlandsnl/bsnBSN
nl/kvkKvK
nl/vatBTW
NO Norwayno/fodselsnummerFødselsnr
no/mvaMVA
no/orgnrOrgnr
NZ New Zealandnz/irdIRD
PA Panamapa/rucRUC
PE Perupe/rucRUC
PH Philippinesph/philidPhilID
PK Pakistanpk/cnicCNIC
PL Polandpl/nipNIP
pl/peselPESEL
pl/regonREGON
PT Portugalpt/ccCC
pt/vatNIF
RO Romaniaro/cnpCNP
ro/vatCIF
RS Serbiars/pibPIB
RU Russiaru/innИНН
SE Swedense/orgnrOrgnr
se/personnummerPN
se/vatMomsnr.
SG Singaporesg/uenUEN
SI Sloveniasi/emsoEMŠO
si/vatDDV
SK Slovakiask/dicIČ DPH
sk/icoIČO
sk/rc
TH Thailandth/tinTIN
TR Turkeytr/tckimlikT.C. Kimlik
tr/vknVKN
TW Taiwantw/ubnUBN
UA Ukraineua/edrpouЄДРПОУ
US United Statesus/einEIN
us/itinITIN
us/rtnRTN
us/ssnSSN
UY Uruguayuy/rutRUT
VE Venezuelave/rifRIF
VN Vietnamvn/mstMST
ZA South Africaza/idnrSA ID

API

Every identifier exports the same interface:

type Validator = {
  name: string;
  localName: string;
  abbreviation: string;
  country?: CountryCode;
  entityType: "person" | "company" | "any";
  compact: (value: string) => string;
  format: (value: string) => string;
  validate: (value: string) => ValidateResult;

  // Optional metadata
  description?: string;
  sourceUrl?: string;
  lengths?: readonly number[];
  examples?: readonly string[];
  aliases?: readonly string[];
  candidatePattern?: string;

  // Available on most validators
  generate?: () => string;
};

type ValidateResult =
  | { valid: true; compact: string }
  | {
      valid: false;
      error: {
        code:
          | "INVALID_FORMAT"
          | "INVALID_LENGTH"
          | "INVALID_CHECKSUM"
          | "INVALID_COMPONENT";
        message: string;
      };
    };

Additional exports

Many person-type validators export parse(), returning structured data extracted from the identifier:

import { cz } from "@stll/stdnum";

cz.rc.parse("7103192745");
// { birthDate: Date, gender: "male" }

Validators with parse(): BA JMBG, BG ЕГН, CN RIC, CU NI, CZ RČ, DK CPR, EE IK, FI HETU, FR NIR, IT CF, KR RRN, KW Civil ID, KZ IIN, LK NIC, MX CURP, MY NRIC, NO Fødselsnr, PL PESEL, RO CNP, SE PN, SI EMŠO, SK RČ, ZA SA ID.

detectNetwork() and the CardNetwork type are top-level named exports:

import { detectNetwork } from "@stll/stdnum";
import type { CardNetwork } from "@stll/stdnum";

detectNetwork("4111111111111111");
// "visa"

Unicode handling

All validators normalize Unicode artifacts before validation: fullwidth digits, various dashes, non-breaking spaces, zero-width characters, and other common OCR/PDF copy-paste issues are handled automatically.

Development

bun install
bun run typecheck
bun test
bun run lint     # oxlint
bun run format   # oxfmt

License

MIT

Keywords

credit-card

FAQs

Package last updated on 13 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts