StutzJS


A tiny but accurate currency amount formatting library for JavaScript and TypeScript

Features

Features


Format

Change 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"

Unformat

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"

Sum

Change the values to see how the sum is calculated.

money.sum(values);

Configuration


Highly Configurable

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;
  });

Developers


Check out the Git Repository. Fork it. Use it for whatever you like!