Rupiah
- Number
- 1500000.5
- Formatted
- Rp1.500.000,50
- In words
- satu juta lima ratus ribu rupiah lima puluh sen
Runs in your browser.
Functions
Section titled “Functions”| Go | TypeScript | Returns |
|---|---|---|
rupiah.Format(a, opts) |
rupiah.format(n, opts?) |
Rp1.500.000,50 |
rupiah.Parse(s) |
rupiah.parse(s) |
The amount (Go: Amount in sen, TypeScript: number in rupiah) |
rupiah.Valid(s) |
rupiah.isValid(s) |
Whether s parses |
rupiah.Terbilang(a) |
rupiah.terbilang(n) |
satu juta lima ratus ribu rupiah lima puluh sen |
Amounts
Section titled “Amounts”- Go uses
rupiah.Amount, anint64in sen, so arithmetic is exact:150_000 * rupiah.Rupiah + 50 * rupiah.Sen. - TypeScript uses a
numberin rupiah. Amounts with sen are limited to below 10 trillion (MAX_SEN_AMOUNT) so they stay exact. Whole amounts go up to 999 trillion (MAX_AMOUNT).
Format options
Section titled “Format options”Go Options |
TypeScript | Effect |
|---|---|---|
Decimals |
decimals |
Always print sen: Rp2.000.000,00 |
OmitSymbol |
symbol: false |
No Rp prefix |
Without Decimals, sen is printed only when it is not zero. Negative amounts are formatted as -Rp1.000.
Parsing
Section titled “Parsing”Parse accepts what people write in Indonesia: an optional Rp, Rp. or IDR prefix, dots as thousands separators, a comma before sen, and a trailing ,-. Rp 25.000,-, IDR 1.500.000,50 and 25000 all parse. Input is limited to 64 characters.
Errors
Section titled “Errors”length, charset, format (misplaced separators, more than two sen digits), range (larger than the supported amount).
Example
Section titled “Example”package main
import ( "fmt"
"github.com/haikalmumtaz233/nusaindex/rupiah")
func main() { price := 1_500_000*rupiah.Rupiah + 50*rupiah.Sen
text, err := rupiah.Format(price, rupiah.Options{}) if err == nil { fmt.Println(text) }
plain, err := rupiah.Format(2_000_000*rupiah.Rupiah, rupiah.Options{Decimals: true, OmitSymbol: true}) if err == nil { fmt.Println(plain) }
fmt.Println(rupiah.Valid("Rp 25.000,-"))
amount, err := rupiah.Parse("Rp 25.000,-") if err == nil { fmt.Println(int64(amount / rupiah.Rupiah)) }
words, err := rupiah.Terbilang(price) if err == nil { fmt.Println(words) }}import * as rupiah from "nusaindex/rupiah";
const price = 1_500_000.5;
const text = rupiah.format(price);if (text.ok) { console.log(text.value);}
const plain = rupiah.format(2_000_000, { decimals: true, symbol: false });if (plain.ok) { console.log(plain.value);}
console.log(rupiah.isValid("Rp 25.000,-"));
const amount = rupiah.parse("Rp 25.000,-");if (amount.ok) { console.log(amount.value);}
const words = rupiah.terbilang(price);if (words.ok) { console.log(words.value);}Rp1.500.000,502.000.000,00true25000satu juta lima ratus ribu rupiah lima puluh sen© 2026 Haikal Mumtaz