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

@pcampus/thai-romanization

v1.0.0

Published

Rule-based Thai to Latin romanization with morpheme segmentation, loanwords, and province support

Downloads

137

Readme

@pcampus/thai-romanization

Rule-based Thai → Latin romanization library. No per-word hardcoded overrides in the core pipeline — segmentation uses a morpheme trie, orthography rules, and lookup tables for loanwords and provinces.

📖 คู่มือการใช้งานฉบับเต็ม: USAGE.md

Install

npm install @pcampus/thai-romanization

Quick start

import { romanize, romanizeSentence } from '@pcampus/thai-romanization';

romanize('สวัสดี');           // 'sawatdi'
romanize('กษัตริย์');         // 'kasatri'
romanize('มกราคม');           // 'mokkarakhom'

romanizeSentence('สวัสดี ครับ'); // 'sawatdi khrap'

API

| Function | Description | |----------|-------------| | romanize(text, options?) | Romanize a single word or compound | | romanizeSentence(text, options?) | Romanize text, preserving spaces and punctuation | | romanizeDetailed(text, options?) | Full pipeline debug output | | romanizeBatch(words[], options?) | Romanize multiple words | | reverseLookup(latin) | Latin → Thai candidates (vocabulary, morphemes, loanwords, provinces) | | segment(text) | Trie-based word segmentation | | splitIntoSyllables(text) | Syllable-level split | | getRomanizationUnits(text) | Internal romanization units |

Options

romanize('สวัสดี', { separator: '-', tone: 'number' });
// separator: '' | '-' | ' '  (default: '')
// tone: 'omit' | 'diacritic' | 'number'  (default: 'omit')

Vocabulary packs

The trie dictionary is split into layered packs:

import { coreVocab, geoVocab, calendarVocab, mergeVocabulary } from '@pcampus/thai-romanization';

const custom = mergeVocabulary(coreVocab, geoVocab);

Optional subpath imports:

import { geoVocab } from '@pcampus/thai-romanization/packs/geo';
import { calendarVocab } from '@pcampus/thai-romanization/packs/calendar';
import { coreVocab } from '@pcampus/thai-romanization/packs/core';

CLI

npx thai-romanize "สวัสดี"
npx thai-romanize --sentence "สวัสดี ครับ"
npx thai-romanize --reverse software
npx thai-romanize --separator - --tone number "มกราคม"

Pipeline

romanize(text, options?)
  ├─ loanword?     → LOANWORD_MAP
  ├─ province?     → PROVINCE_ROMAN
  └─ segment + rules
       ├─ applySyllableBoundaries()
       ├─ Trie longest-match (vocabulary packs)
       ├─ monthRules (-าคม → khom/akhom)
       └─ applyTone()

Development

npm test          # vitest
npm run build     # tsup → dist/
npm run playground  # Next.js demo UI

Publish

npm login
npm publish

License

MIT