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

thai-citizenid-gen

v2.0.2

Published

A library for generating valid Thai Citizen IDs and mock Thai personal data. Updated to correctly follow the ID generation algorithm and resolve security vulnerabilities in dependencies.

Readme

Thai Citizen ID Generator

npm version license GitHub stars Issues

Generate valid Thai national ID numbers and mock Thai person data — perfect for testing registration systems and mock user data.

Table of Contents

Features

  • ✅ Generate valid 13-digit Thai citizen ID numbers
  • ✅ Random or customizable Thai name, gender, religion, birth year, etc.
  • ✅ Export as objects (for use in JSON, CSV, etc.)
  • ✅ Deterministic generation with seed
  • ✅ Tiny and zero-dependency core

Installation

npm install thai-citizenid-gen

Usage

Basic Usage: Generate People Randomly

import { generatePeople } from 'thai-citizenid-gen';

// Generate 10 people with random name, gender, birthdate, religion, etc.
const people = generatePeople(10);
console.log(people);

Advanced Usage: Customize the Generated Data

You can control the result by passing an options object:

interface GenerateOptions {
  gender: 'ชาย' | 'หญิง';      // Force male or female
  bornYear: number;            // Specify a fixed birth year
  religion: string;            // Specify a religion (e.g., 'พุทธ', 'คริสต์')
  seed: number;                // Use for consistent, repeatable output
}

Example: Generate 5 people with fixed attributes

import { generatePeople } from 'thai-citizenid-gen';

const people = generatePeople(5, {
  gender: 'หญิง',
  bornYear: 1990,
  religion: 'พุทธ',
  seed: 42,
});

console.log(people);

Auto-incremented seed

// If seed = 42
// Person 1 -> seed 42
// Person 2 -> seed 43
// ...

Export Generated Data to Files

Exports to both .json and .csv in the output/ directory.

import { exportPeople } from 'thai-citizenid-gen';

exportPeople(10, {
  gender: 'ชาย',
  bornYear: 1995,
  religion: 'พุทธ',
  seed: 1000,
});

Output files:

output/people.json
output/people.csv

Generate a Single Person

import { generateThaiID, generateMockPerson } from 'thai-citizenid-gen';

const person = generateMockPerson({
  gender: 'ชาย',
  seed: 99,
});
console.log(person);

const id = generateThaiID(); // just the 13-digit ID
console.log('Thai ID:', id);

API Reference

generateMockPerson(options?: Partial<GenerateOptions>): Person

Generates a single mock Thai person object.

Options (optional):

interface GenerateOptions {
  gender: 'ชาย' | 'หญิง';
  bornYear: number;
  religion: string;
  seed: number;
}

generatePeople(count: number, options?: Partial<GenerateOptions>): Person[]

Generate multiple people.

  • count: number of people to generate
  • options: same as above
  • Each person will auto-increment the seed (if provided)

Example:

generatePeople(5, { gender: 'หญิง', seed: 100 });

exportPeople(count: number, options?: Partial<GenerateOptions>): void

Generate and export people data to:

  • output/people.json
  • output/people.csv

Example:

exportPeople(10, { bornYear: 1995, religion: 'พุทธ' });

generateThaiID(): string

Generates a valid Thai citizen ID (13 digits) using checksum logic.

const id = generateThaiID();

Person Object Structure

interface Person {
  id: string;
  firstName: string;
  lastName: string;
  gender: 'ชาย' | 'หญิง';
  birthDate: string;
  age: number;
  religion: string;
  laserCode: string;
  issuedDate: string;
  expiredDate: string;
  englishName: string;
  province: string;
  district: string;
  subdistrict: string;
  postcode: string;
  address: string;
}

Sample output:

JSON

[
  {
    "id": "2657827304927",
    "firstName": "สมหญิง",
    "lastName": "บุญมา",
    "gender": "หญิง",
    "birthDate": "1967-10-08",
    "age": 57,
    "religion": "พุทธ",
    "laserCode": "JT5802609-356",
    "issuedDate": "2024-05-20",
    "expiredDate": "2034-05-18",
    "englishName": "สมหญิง บุญมา",
    "province": "เชียงใหม่",
    "district": "เมืองเชียงใหม่",
    "subdistrict": "แขวงเมืองเชียงใหม่",
    "postcode": "50200",
    "address": "123 หมู่ 4 ต.แขวงเมืองเชียงใหม่ อ.เมืองเชียงใหม่ จ.เชียงใหม่ 50200"
  },
]

CSV

id,firstName,lastName,gender,birthDate,age,religion,laserCode,issuedDate,expiredDate,englishName,province,district,subdistrict,postcode,address
2657827304927,สมหญิง,บุญมา,หญิง,1967-10-08,57,พุทธ,JT5802609-356,2024-05-20,2034-05-18,สมหญิง บุญมา,เชียงใหม่,เมืองเชียงใหม่,แขวงเมืองเชียงใหม่,50200,"123 หมู่ 4 ต.แขวงเมืองเชียงใหม่ อ.เมืองเชียงใหม่ จ.เชียงใหม่ 50200"

Use Cases

  • Testing registration forms and e-KYC systems.

  • Generating fake user data for development or staging environments.

  • Populating unit tests and CI/CD pipelines with realistic mock data.

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you have improvements or bug fixes.

License

MIT Feel free to use, modify, and distribute for personal or commercial use.