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

iin-bin

v2.0.0

Published

Validate and parse Kazakhstan IIN (Individual Identification Number) and BIN (Business Identification Number)

Readme

iin-bin

Validate and parse Kazakhstan IIN (Individual Identification Number) and BIN (Business Identification Number) — the 12-digit identifiers used for individuals and legal entities in Kazakhstan.

What is IIN/BIN?

Features

  • Full checksum validation (two-stage mod-11 algorithm)
  • Automatic IIN vs BIN detection
  • IIN: extracts gender, birth date, registration number
  • BIN: extracts registration date, legal entity type, structural attribute
  • TypeScript-first with full type definitions
  • Zero dependencies
  • ESM and CommonJS support

Install

npm install iin-bin

Usage

Parse (with validation)

import { parse } from "iin-bin";

const result = parse("780421334966");

if (result.type === "IIN") {
  result.gender; // "male"
  result.birthDate; // Date(1978-04-21)
  result.birthYear; // 1978
  result.birthMonth; // 4
  result.birthDay; // 21
  result.registrationNumber; // "3496"
}

if (result.type === "BIN") {
  result.registrationYear; // 14
  result.registrationMonth; // 12
  result.legalEntityType; // "resident"
  result.legalEntityAttribute; // "head-office"
}

Validate without throwing

import { isValid, validate } from "iin-bin";

isValid("780421334966"); // true
isValid("000000000000"); // false

const error = validate("123");
if (error) {
  error.code; // "INVALID_LENGTH"
  error.message; // "Expected 12 digits, got 3"
}

API

parse(value: string): ParseResult

Parses and validates a 12-digit IIN or BIN string. Throws IINBINError if invalid.

Returns IINData or BINData depending on the detected type.

isValid(value: string): boolean

Returns true if the value is a valid IIN or BIN, false otherwise.

validate(value: string): IINBINError | null

Returns null if valid, or an IINBINError with a descriptive code and message.

Error codes

| Code | Description | | -------------------- | ----------------------------------------------- | | INVALID_LENGTH | Not exactly 12 characters | | INVALID_CHARACTERS | Contains non-digit characters | | INVALID_CHECKSUM | Fails control number verification | | INVALID_DATE | IIN contains an impossible date | | INVALID_STRUCTURE | Unexpected digit values in structural positions |

Types

type IINData = {
  value: string;
  type: "IIN";
  gender: "male" | "female";
  birthDate: Date;
  birthYear: number;
  birthMonth: number;
  birthDay: number;
  registrationNumber: string;
};

type BINData = {
  value: string;
  type: "BIN";
  registrationYear: number;
  registrationMonth: number;
  legalEntityType:
    | "resident"
    | "non-resident"
    | "individual-entrepreneur"
    | "reserved";
  legalEntityAttribute:
    | "head-office"
    | "branch-office"
    | "representative-office"
    | "isolated-structural-unit"
    | "peasant-farming"
    | null;
};

Development

npm install
npm test          # run tests
npm run build     # build for production
npm run typecheck # type-check without emitting

License

MIT