A tiny but accurate currency amount formatting library for JavaScript and TypeScript
FeaturesChange the currency or the number to see how the library formats them.
CHF 123'465'479.66
money .of("CHF", "123465479.66") .formatMoney(); // "CHF 123'465'479.66"
Change the formatted value and see how it is parsed.
CHF
123465479.66
var parsed = money .parse("CHF 123'465'479.66"); parsed.getAmount(); // 123465479.66 parsed.getCurrencyCode(); // "CHF"
Change the values to see how the sum is calculated.
money.sum(values);
The library supports a wide variety of configuration options.
CHF
money.config().reset();
Custom Delimiters | Custom Decimals | Custom Negative Sign |
---|---|---|
money.config().useGroupDelimiter(","); money.config().useDecimalDelimiter(","); |
money.config().useRoundHalfUp(true); money.config().useDecimalPlaces(5); |
money.config().useNegativeSign("()"); money.config().useNegativeSign("N"); |
money.config().useFormatter( function (amount, currency) { return amount + " " + currency; });