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

@itsdreamy/fay-indo-formatter

v1.0.0

Published

Lightweight Indonesian utility formatters for Rupiah, dates, number to words, and phone validation.

Readme

fay-indo-formatter

npm version License: MIT Zero Dependencies Node.js

A zero-dependency Node.js utility library with common formatting functions tailored for Indonesian developers.


✨ Key Features

| Feature | Description | |---|---| | 💰 Rupiah Formatter | Convert numbers to Rp currency strings with thousand separators | | 📅 Indonesian Date Formatter | Format dates using full Bahasa Indonesia month & day names | | 🔢 Terbilang | Spell out numbers in Indonesian words (e.g. invoice billing) | | 📱 Phone Validator | Validate Indonesian mobile numbers (08xx, 628xx, +628xx) | | 🧹 Phone Sanitizer | Normalize any phone format to the standard national format 08xx | | 🚫 Zero Dependencies | Pure Node.js — nothing to audit, nothing extra to install |


📦 Installation

npm install fay-indo-formatter

🚀 Quick Start

const {
  toRupiah,
  formatDateID,
  terbilang,
  isValidPhoneID,
  sanitizePhoneID,
} = require('fay-indo-formatter');

console.log(toRupiah(15000));                        // "Rp 15.000"
console.log(formatDateID('2026-10-30'));              // "30 Oktober 2026"
console.log(terbilang(125000));                      // "seratus dua puluh lima ribu"
console.log(isValidPhoneID('+6281234567890'));        // true
console.log(sanitizePhoneID('+62 812-3456-7890'));   // "081234567890"

📖 Usage Examples

toRupiah(number, options?)

const { toRupiah } = require('fay-indo-formatter');

toRupiah(15000);
// → "Rp 15.000"

toRupiah(1500000);
// → "Rp 1.500.000"

toRupiah(1500000.5, { decimal: 2 });
// → "Rp 1.500.000,50"

toRupiah(75000, { withPrefix: false });
// → "75.000"

toRupiah(0);
// → "Rp 0"

formatDateID(date, format?)

const { formatDateID } = require('fay-indo-formatter');

// Default format: "DD MMMM YYYY"
formatDateID('2026-10-30');
// → "30 Oktober 2026"

// Short month
formatDateID('2026-10-30', 'DD MMM YYYY');
// → "30 Okt 2026"

// With full day name
formatDateID('2026-10-30', 'dddd, DD MMMM YYYY');
// → "Jumat, 30 Oktober 2026"

// With short day name
formatDateID('2026-10-30', 'ddd, DD MMMM YYYY');
// → "Jum, 30 Oktober 2026"

// With time
formatDateID(new Date(), 'DD/MM/YYYY HH:mm:ss');
// → e.g. "30/10/2026 20:05:00"

// From a Date object
formatDateID(new Date('2026-06-17'), 'D MMMM YYYY');
// → "17 Juni 2026"

Available format tokens:

| Token | Output | Example | |--------|--------|---------| | YYYY | 4-digit year | 2026 | | YY | 2-digit year | 26 | | MMMM | Full month (Indonesian) | Oktober | | MMM | Short month (Indonesian) | Okt | | MM | 2-digit month | 10 | | M | Month, no padding | 10 | | DD | 2-digit day | 05 | | D | Day, no padding | 5 | | dddd | Full day name (Indonesian) | Jumat | | ddd | Short day name (Indonesian) | Jum | | HH | Hours (00–23) | 20 | | mm | Minutes (00–59) | 05 | | ss | Seconds (00–59) | 00 |


terbilang(number)

const { terbilang } = require('fay-indo-formatter');

terbilang(0);         // "nol"
terbilang(11);        // "sebelas"
terbilang(100);       // "seratus"
terbilang(1000);      // "seribu"
terbilang(125000);    // "seratus dua puluh lima ribu"
terbilang(1000000);   // "satu juta"
terbilang(1500000);   // "satu juta lima ratus ribu"

// Practical use: invoice amounts
const amount = 750000;
console.log(`Terbilang: ${terbilang(amount)} rupiah`);
// → "Terbilang: tujuh ratus lima puluh ribu rupiah"

isValidPhoneID(phoneNumber)

const { isValidPhoneID } = require('fay-indo-formatter');

isValidPhoneID('081234567890');       // true
isValidPhoneID('6281234567890');      // true
isValidPhoneID('+6281234567890');     // true
isValidPhoneID('+62 812-3456-7890'); // true  (spaces & dashes OK)
isValidPhoneID('(+62) 812.3456.7890'); // true

isValidPhoneID('021-555-1234');      // false (Jakarta landline)
isValidPhoneID('08123456');          // false (too short)
isValidPhoneID('1234');              // false
isValidPhoneID(81234567890);         // false (not a string)

sanitizePhoneID(phoneNumber)

const { sanitizePhoneID } = require('fay-indo-formatter');

sanitizePhoneID('+62 812-3456-7890');    // "081234567890"
sanitizePhoneID('6281234567890');        // "081234567890"
sanitizePhoneID('081234567890');         // "081234567890"
sanitizePhoneID('(+62) 812-3456-7890'); // "081234567890"

// Throws for invalid input
sanitizePhoneID('1234');  // Error: not a valid Indonesian phone number

📚 API Reference

toRupiah(number, options?)

| Parameter | Type | Default | Description | |---|---|---|---| | number | number | — | The value to format. Finite numbers only. | | options.withPrefix | boolean | true | Prepend "Rp " to the result. | | options.decimal | number | 0 | Number of decimal places to show. Uses comma (,) as decimal separator per Indonesian convention. |

Returns: string
Throws: TypeError if number is not a finite number.


formatDateID(date, format?)

| Parameter | Type | Default | Description | |---|---|---|---| | date | Date \| string \| number | — | A Date object, ISO 8601 string, or Unix timestamp (ms). | | format | string | 'DD MMMM YYYY' | Format string using the tokens listed above. |

Returns: string
Throws: TypeError if the date cannot be parsed or format is not a string.


terbilang(number)

| Parameter | Type | Description | |---|---|---| | number | number | Non-negative integer. Supports up to 999,999,999,999,999. |

Returns: string — Indonesian words for the number.
Throws: TypeError if not a finite number; RangeError if negative or too large.


isValidPhoneID(phoneNumber)

| Parameter | Type | Description | |---|---|---| | phoneNumber | string | Phone number in any common format. |

Returns: boolean — true if the number matches a valid Indonesian mobile pattern.

Accepted prefixes (after stripping spaces/dashes):

  • 08xx — national format
  • 628xx — international without plus
  • +628xx — E.164 international format

sanitizePhoneID(phoneNumber)

| Parameter | Type | Description | |---|---|---| | phoneNumber | string | Phone number in any valid format. |

Returns: string — Phone number normalised to 08xxxxxxxxx.
Throws: TypeError if argument is not a string; Error if the number is invalid.


🤝 Contributing

Contributions, issues, and feature requests are welcome!
Feel free to open an issue or submit a pull request.


📄 License

MIT © 2026 itsdreamy-fay