thai-addr
v0.1.0
Published
Parse Thai postal addresses into structured fields for DBD, DGA, and form ingestion workflows.
Maintainers
Readme
thai-addr
Parse Thai postal addresses into structured fields for DBD, DGA, and form ingestion workflows.
import { parseAddress } from 'thai-addr';
const parsed = parseAddress(
'99/9 หมู่ที่ 5 ซอยสุขุมวิท 31 ถนนสุขุมวิท แขวงคลองตันเหนือ เขตวัฒนา กรุงเทพมหานคร 10110',
);
console.log(parsed);{
houNum: '99/9',
bdgNme: '',
soiNme: 'สุขุมวิท 31',
mooNum: '5',
steNme: 'สุขุมวิท',
tmbNme: 'คลองตันเหนือ',
ampNme: 'วัฒนา',
prvNme: 'กรุงเทพมหานคร',
posCde: '10110'
}Install
npm install thai-addrAPI
parseAddress(address, options?)
Returns a ParsedAddress object:
| Field | Meaning |
| --- | --- |
| houNum | House number |
| bdgNme | Building, village, room, floor, or other leftover place text |
| soiNme | Soi, alley, lane, or junction |
| mooNum | Moo number |
| steNme | Street or road |
| tmbNme | Subdistrict / tambon / khwaeng |
| ampNme | District / amphoe / khet |
| prvNme | Province |
| posCde | Postal code |
Options:
type ParseAddressOptions = {
preservePrefix?: boolean;
profile?: 'generic' | 'dbd' | 'dga' | 'thaid';
};When preservePrefix is true, fields keep labels such as ถนน, ตำบล, อำเภอ, and จังหวัด.
Profiles tune how much the parser should infer from unlabeled text:
| Profile | Use case |
| --- | --- |
| generic | Default balanced parser for general Thai address strings |
| dbd | Conservative parsing for DBD-style business address data |
| dga | Conservative parsing for government structured/reference data |
| thaid | More helpful inference for person/form style addresses, including unlabeled Bangkok tails such as บางนา บางนา กรุงเทพ |
parseAddress('12/34 อาคารตัวอย่าง ซ.ตัวอย่าง7 บางนา บางนา กรุงเทพ 10260', {
profile: 'thaid',
});Notes
Thai addresses are semi-structured. This package uses deterministic parsing rules and is best suited for data cleanup, import pipelines, and forms where the original source is already a Thai address string. For maximum accuracy at scale, validate parsed province, district, and subdistrict names against an official administrative-area dataset.
