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

@llein/vn-cccd-parser

v1.1.0

Published

Parse 12-digit Vietnam National Citizen Identity (CCCD/VNeID) number into birth year, century, gender, and birth province.

Readme

vn-cccd-parser

Comprehensive, zero-dependency parser & validator for Vietnam Citizen Identity Cards (CCCD / VNeID) and Chip QR Codes according to the Vietnam Citizen Identity Law.

npm version npm downloads bundle size license


⚡ Highlights

  • Zero Dependencies: Pure TypeScript, minimal footprint (< 3KB gzipped).
  • Comprehensive Data: Full official mapping of all 63 Vietnam provinces/cities, regions (Bắc / Trung / Nam), and municipality flags.
  • Law-Compliant: Covers centuries 20 through 24 (1900 to 2399) and renewal milestones at ages 25, 40, and 60 (Luật Căn cước Việt Nam).
  • Chip QR Parser: Decode raw QR code strings printed on chip-based CCCD and verify cross-field consistency.
  • Mock Data Generator: Generate valid CCCD numbers for testing and database seeds.
  • Dual Export: ESM (.mjs) and CommonJS (.js) with full TypeScript declarations (.d.ts).

📦 Installation

# Using npm
npm install vn-cccd-parser

# Using pnpm
pnpm add vn-cccd-parser

# Using yarn
yarn add vn-cccd-parser

🚀 Quickstart

1. Parse 12-Digit CCCD Number

import { parseCCCD } from 'vn-cccd-parser';

const result = parseCCCD('001095012345');

if (result.isValid) {
  console.log(result.province);        // "Thành phố Hà Nội"
  console.log(result.region);          // "Miền Bắc"
  console.log(result.isMunicipality);  // true
  console.log(result.gender);          // "Nam"
  console.log(result.birthYear);       // 1995
  console.log(result.age);             // 31
  console.log(result.renewalMilestones);
  // {
  //   age25Year: 2020,
  //   age40Year: 2035,
  //   age60Year: 2055,
  //   nextRenewalYear: 2035,
  //   isExpired: false
  // }
}

2. Parse Chip CCCD QR Code

import { parseCCCDQr } from 'vn-cccd-parser';

// Format: CCCD|OldCMND|FullName|DOB|Gender|Address|IssueDate
const qrString = '001095012345|012345678|Nguyễn Văn An|25101995|Nam|123 Phố Huế, Hà Nội|10122021';
const citizen = parseCCCDQr(qrString);

console.log(citizen.fullName);     // "Nguyễn Văn An"
console.log(citizen.dateOfBirth);  // "1995-10-25"
console.log(citizen.isConsistent); // true (CCCD number matches DOB and gender)

3. Generate Mock Data for Tests

import { generateMockCCCD } from 'vn-cccd-parser';

const mockHanoi = generateMockCCCD({ provinceCode: '001', gender: 'Nữ', birthYear: 2002 });
console.log(mockHanoi); // e.g. "001302847291"

📖 API Reference

Functions

| Function | Parameters | Returns | Description | | :--- | :--- | :--- | :--- | | parseCCCD | (id: string) | CCCDParseResult | Parses 12-digit CCCD and returns full profile | | isValidCCCD | (id: string) | boolean | Quick boolean validator | | parseCCCDQr | (qrString: string) | CCCDQrResult | Parses chip CCCD QR code payload | | getRenewalMilestones | (birthYear, currentYear?) | RenewalMilestones | Calculates ages 25, 40, 60 renewal deadlines | | generateMockCCCD | (options?) | string | Generates a valid 12-digit mock CCCD |


📄 License

MIT © Open Source Developer