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

sinhala-numwords

v1.0.0

Published

Convert numbers to Sinhala words and back — for payroll, invoices, cheques, and legal documents.

Downloads

344

Readme

sinhala-numwords

The first npm package to convert numbers to Sinhala (සිංහල) words — zero dependencies, TypeScript-first. Convert numbers (including decimals, currency amounts, and ordinals) to Sinhala words, and back — useful for payroll slips, invoices, cheques, and legal documents.

Install

npm install sinhala-numwords

Quick start

import { toWords, toNumber } from 'sinhala-numwords';

toWords(35); // 'තිස් පහ'
toWords(2550.75, { currency: true }); // 'රුපියල් දෙදහස් පන්සිය පනහයි ශත හැත්තෑ පහ'
toNumber('තිස් පහ'); // 35

A default export is also available for those who prefer it:

import sinhalaNum from 'sinhala-numwords';

sinhalaNum.toWords(350);
sinhalaNum.toNumber('තුන්සිය පනහ');

toWords(num, options?)

Converts a number to its Sinhala word form.

  • num — a number between -9,999,999,999 and 9,999,999,999. May include decimals.
  • options.currency — read as money (rupees and cents).
  • options.ordinal — read as an ordinal (1st, 2nd, 3rd, ...).
  • options.assert — append the assertive particle "යි" (e.g. "පහ" -> "පහයි").

Plain numbers

toWords(0); // 'බිංදුව'
toWords(5); // 'පහ'
toWords(35); // 'තිස් පහ'
toWords(100); // 'සියය'
toWords(200); // 'දෙසිය'
toWords(1000); // 'එක් දහස්'
toWords(1500); // 'එක් දහස් පන්සිය'
toWords(100000); // 'එක් ලක්ෂ'
toWords(10000000); // 'එක් කෝටි'
toWords(-5); // 'ඍණ පහ'

Decimal numbers

Read digit-by-digit after "දශම" (point):

toWords(13.14); // 'දහතුනයි දශම එකයි හතර'
toWords(0.5); // 'බිංදුවයි දශම පහ'
toWords(501.231); // 'පන්සිය එකයි දශම දෙකයි තුනයි එක'
toWords(-13.14); // 'ඍණ දහතුනයි දශම එකයි හතර'

Ordinal numbers (ordinal: true)

toWords(1, { ordinal: true }); // 'පළවෙනි'
toWords(2, { ordinal: true }); // 'දෙවෙනි'
toWords(10, { ordinal: true }); // 'දහවෙනි'
toWords(35, { ordinal: true }); // 'තිස් පස්වෙනි'

Negative integers are prefixed with "ඍණ":

toWords(-3, { ordinal: true }); // 'ඍණ තුන්වෙනි'
toWords(-35, { ordinal: true }); // 'ඍණ තිස් පස්වෙනි'

Decimal ordinals render the last fractional digit as an ordinal:

toWords(13.14, { ordinal: true }); // 'දහතුනයි දශම එකයි හතරවෙනි'
toWords(3.1, { ordinal: true }); // 'තුනයි දශම එක්වෙනි'

0 has no ordinal form and throws a RangeError for ordinal: true.

Currency amounts (currency: true)

Prefixes the result with "රුපියල්" (rupees):

toWords(2550, { currency: true }); // 'රුපියල් දෙදහස් පන්සිය පනහ'
toWords(0, { currency: true }); // 'රුපියල් බිංදුව'
toWords(101, { currency: true }); // 'රුපියල් එකසිය එක'

Decimal amounts are read as rupees and cents ("ශත"), rounded to the nearest cent:

toWords(2550.75, { currency: true }); // 'රුපියල් දෙදහස් පන්සිය පනහයි ශත හැත්තෑ පහ'
toWords(101.05, { currency: true }); // 'රුපියල් එකසිය එකයි ශත පහ'
toWords(101.0, { currency: true }); // 'රුපියල් එකසිය එක' (no cents when amount is whole)

currency: true does not support negative amounts and throws a RangeError.

Combine with ordinal: true to read the cents as an ordinal:

toWords(13.14, { currency: true, ordinal: true }); // 'රුපියල් දහතුනයි ශත දාහතරවෙනි'
toWords(2550.75, { currency: true, ordinal: true }); // 'රුපියල් දෙදහස් පන්සිය පනහයි ශත හැත්තෑ පස්වෙනි'

Assertive form (assert: true)

Appends "යි" to the final word for emphasis, e.g. when reading a final amount aloud:

toWords(5, { assert: true }); // 'පහයි'
toWords(-5, { assert: true }); // 'ඍණ පහයි'
toWords(13.14, { assert: true }); // 'දහතුනයි දශම එකයි හතරයි'
toWords(2550, { currency: true, assert: true }); // 'රුපියල් දෙදහස් පන්සිය පනහයි'
toWords(2550.75, { currency: true, assert: true }); // 'රුපියල් දෙදහස් පන්සිය පනහයි ශත හැත්තෑ පහයි'

Ignored when ordinal is set, since ordinal forms ("...වෙනි") are already grammatically complete:

toWords(3, { ordinal: true, assert: true }); // 'තුන්වෙනි'
toWords(13.14, { ordinal: true, assert: true }); // 'දහතුනයි දශම එකයි හතරවෙනි'

Combining options

ordinal, currency, and assert can all be combined. Here's the full matrix for 35 and 13.14:

| ordinal | currency | assert | toWords(35, ...) | toWords(13.14, ...) | | --- | --- | --- | --- | --- | | – | – | – | තිස් පහ | දහතුනයි දශම එකයි හතර | | – | – | ✓ | තිස් පහයි | දහතුනයි දශම එකයි හතරයි | | – | ✓ | – | රුපියල් තිස් පහ | රුපියල් දහතුනයි ශත දාහතර | | – | ✓ | ✓ | රුපියල් තිස් පහයි | රුපියල් දහතුනයි ශත දාහතරයි | | ✓ | – | – | තිස් පස්වෙනි | දහතුනයි දශම එකයි හතරවෙනි | | ✓ | – | ✓ | තිස් පස්වෙනි (assert ignored) | දහතුනයි දශම එකයි හතරවෙනි (assert ignored) | | ✓ | ✓ | – | රුපියල් තිස් පස්වෙනි | රුපියල් දහතුනයි ශත දාහතරවෙනි | | ✓ | ✓ | ✓ | රුපියල් තිස් පස්වෙනි (assert ignored) | රුපියල් දහතුනයි ශත දාහතරවෙනි (assert ignored) |

Errors

| Input | Throws | | --- | --- | | Not a number (string, null, undefined, array, ...) | TypeError | | NaN | TypeError | | Infinity / -Infinity | RangeError | | Outside ±9,999,999,999 | RangeError | | ordinal: true with num === 0 | RangeError | | currency: true with a negative num | RangeError |

toNumber(text)

Parses a Sinhala cardinal number word string back into a number — the inverse of toWords for its plain or currency integer output (not ordinal or decimal).

toNumber('තිස් පහ'); // 35
toNumber('දෙසිය'); // 200
toNumber('එක් දහස් පන්සිය'); // 1500
toNumber('ඍණ පහ'); // -5
toNumber('රුපියල් දෙදහස් පන්සිය පනහ'); // 2550
toNumber('රුපියල් දෙදහස් පන්සිය පනහයි'); // 2550 (with assertive "යි", also accepted)
toNumber('රුපියල් එකසිය එක'); // 101

Errors

| Input | Throws | | --- | --- | | Not a string | TypeError | | Empty string | SyntaxError | | Unrecognized or non-Sinhala words (including digits like '350') | SyntaxError | | Mixed Sinhala/Latin text | SyntaxError |

License

MIT

Author

Inuka Wijerathnainukawijerathna.me · GitHub · LinkedIn