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

thaibath

v1.0.0

Published

Thai Baht currency text conversion and formatting utilities

Readme

ThaiBath

npm version npm downloads bundle size license

Thai Baht currency text conversion and formatting utilities. Converts numbers to Thai Baht words, Thai numerals, and formatted currency strings.

Install

npm install thaibath
# or
bun add thaibath
# or
pnpm add thaibath

Usage

import {
  bahtText,
  numberToThaiText,
  satangToText,
  parseBahtText,
  isValidBahtText,
  format,
  formatLong,
  thaiNumerals,
  parseThaiNumerals,
  roundToSatang,
  roundToBaht,
  getBahtSatang,
} from 'thaibath'

bahtText

Convert a number to Thai Baht text, matching Google Sheets BAHTTEXT output.

bahtText(100)        // "หนึ่งร้อยบาทถ้วน"
bahtText(100.50)     // "หนึ่งร้อยบาทห้าสิบสตางค์"
bahtText(11)         // "สิบเอ็ดบาทถ้วน"
bahtText(21)         // "ยี่สิบเอ็ดบาทถ้วน"
bahtText(201)        // "สองร้อยหนึ่งบาทถ้วน"
bahtText(0.5)        // "ห้าสิบสตางค์"
bahtText(-100)       // "ลบหนึ่งร้อยบาทถ้วน"
bahtText(1_234_567)  // "หนึ่งล้านสองแสนสามหมื่นสี่พันห้าร้อยหกสิบเจ็ดบาทถ้วน"
bahtText('1,000')    // "หนึ่งพันบาทถ้วน"

numberToThaiText

Convert a number to Thai words without currency suffix.

numberToThaiText(0)     // "ศูนย์"
numberToThaiText(21)    // "ยี่สิบเอ็ด"
numberToThaiText(100)   // "หนึ่งร้อย"
numberToThaiText(201)   // "สองร้อยหนึ่ง"
numberToThaiText(-10)   // "ลบสิบ"

satangToText

Convert satang (0-99) to Thai text.

satangToText(0)   // "ศูนย์สตางค์"
satangToText(50)  // "ห้าสิบสตางค์"
satangToText(99)  // "เก้าสิบเก้าสตางค์"

parseBahtText

Parse Thai Baht text back to a number. Returns null for invalid input.

parseBahtText('หนึ่งร้อยบาทถ้วน')         // 100
parseBahtText('หนึ่งบาทห้าสิบสตางค์')     // 1.5
parseBahtText('ลบสิบเอ็ดบาทถ้วน')        // -11
parseBahtText('invalid')                // null

isValidBahtText

Check if a string is valid Thai Baht text.

isValidBahtText('หนึ่งร้อยบาทถ้วน')  // true
isValidBahtText('hello')           // false

format

Format a number as Thai Baht currency with optional symbol.

format(1234.56)                     // "฿1,234.56"
format(1234.56, { symbol: false })  // "1,234.56"
format(1234, { decimals: 0 })       // "฿1,234"
format(-1234.56)                    // "฿-1,234.56"

formatLong

Format a number with Thai word labels.

formatLong(1234)                    // "1,234 บาทถ้วน"
formatLong(1234.56)                 // "1,234 บาท 56 สตางค์"
formatLong(1234, { decimals: 2 })   // "1,234 บาท 00 สตางค์"
formatLong(-1234.56)                // "-1,234 บาท 56 สตางค์"

thaiNumerals

Convert Arabic numerals to Thai numerals.

thaiNumerals(123)       // "๑๒๓"
thaiNumerals(1234.56)   // "๑๒๓๔.๕๖"
thaiNumerals(-100)      // "-๑๐๐"
thaiNumerals('1,234')   // "๑,๒๓๔"

parseThaiNumerals

Parse Thai numerals back to a number. Returns null for invalid input.

parseThaiNumerals('๑๒๓')          // 123
parseThaiNumerals('๑,๒๓๔.๕๖')    // 1234.56
parseThaiNumerals('hello')        // null

roundToSatang / roundToBaht

Round a number to satang (2 decimals) or whole baht with configurable mode.

roundToSatang(100.555)           // 100.56
roundToSatang(100.551, 'ceil')   // 100.56
roundToSatang(100.559, 'floor')  // 100.55

roundToBaht(100.5)               // 101
roundToBaht(100.4)               // 100
roundToBaht(100.1, 'ceil')       // 101

getBahtSatang

Split a number into baht and satang components.

getBahtSatang(1234.56)   // { baht: 1234, satang: 56 }
getBahtSatang(0.05)      // { baht: 0, satang: 5 }
getBahtSatang(-1234.56)  // { baht: -1234, satang: 56 }
getBahtSatang('1234.56') // { baht: 1234, satang: 56 }

API Reference

bahtText(num, options?)

| Param | Type | Default | Description | |---|---|---|---| | num | number \| string | required | The amount to convert | | options.unit | string | "บาท" | Currency unit word | | options.suffix | string | "ถ้วน" | Suffix for whole amounts | | options.subUnit | string | "สตางค์" | Sub-unit word for decimals |

format(amount, options?)

| Param | Type | Default | Description | |---|---|---|---| | amount | number | required | The amount to format | | options.symbol | boolean | true | Show baht symbol | | options.decimals | number | 2 | Decimal places |

roundToSatang / roundToBaht

| Mode | Description | |---|---| | "round" | Round half-up (default) | | "ceil" | Round up | | "floor" | Round down |

Error Handling

Functions throw TypeError for NaN or Infinity inputs. parseBahtText and parseThaiNumerals return null for invalid input. Numbers outside safe integer range throw RangeError.

Grammar

Output matches Google Sheets BAHTTEXT function conventions:

| Number | Output | |---|---| | 11 | สิบเอ็ดบาทถ้วน | | 21 | ยี่สิบเอ็ดบาทถ้วน | | 31 | สามสิบเอ็ดบาทถ้วน | | 101 | หนึ่งร้อยหนึ่งบาทถ้วน | | 201 | สองร้อยหนึ่งบาทถ้วน | | 1001 | หนึ่งพันหนึ่งบาทถ้วน | | 3061 | สามพันหกสิบเอ็ดบาทถ้วน | | 51,000,001 | ห้าสิบเอ็ดล้านหนึ่งบาทถ้วน |

License

MIT