Thai Citizen ID validation library available in Rust, Python, Node.js, and WebAssembly.
The library name 'kon-jing-jing' (คนจริงจริง) means 'real person' in Thai.
| Language | Package | Install |
|---|---|---|
| Rust | packages/konjingjing | cargo add konjingjing |
| Python | packages/konjingjing-python | pip install konjingjing |
| Node.js | packages/konjingjing-node | npm install konjingjing |
| WASM | packages/konjingjing-wasm | npm install konjingjing-wasm |
| Use Case | Package | Why |
|---|---|---|
| Node.js / Bun / Deno | konjingjing |
Native binding, fastest performance |
| Browser | konjingjing-wasm |
Runs in browser, no server needed |
| Edge / Serverless | konjingjing-wasm |
Portable, no native dependencies |
| Cloudflare Workers | konjingjing-wasm |
WASM supported, native bindings not |
TL;DR: Use
konjingjingfor server-side Node.js. Usekonjingjing-wasmfor browsers and edge runtimes.
All packages export these functions:
Validates a Thai National ID checksum.
Extracts meaning from a Thai National ID:
| Field | Type | Description |
|---|---|---|
person_type_code |
number |
Person type (1-8) |
person_type_description |
string |
Thai description |
person_type_description_en |
string |
English description |
province_code |
number? |
Province code (10-96) |
province_name_th |
string? |
Thai province name |
province_name_en |
string? |
English province name |
amphoe_code |
number? |
District code |
amphoe_name |
string? |
District name (Thai) |
is_valid |
boolean |
Checksum validity |
Returns null if the ID format is invalid (not 13 digits).
Uses mise for task running.
mise run test # Run all tests
mise run test:rust # Run Rust tests
mise run test:python # Run Python tests
mise run test:node # Run Node tests- Validate input is exactly 13 digits
- Calculate weighted checksum:
sum(digit[i] * (13 - i))for i in 0..12 - Verify:
(11 - sum % 11) % 10 == digit[12]
ISC