anyamount — money & numbers: Prices, quantities and units written the way each locale writes them. One call, any currency.
▸about anyamount
Formats a number the way the locale writes it — compact ("1.2M"), money ("€1,999.00"), units ("3.2 GB") — and reads a typed amount back into a number.
- wraps
- Intl.NumberFormat
- install
- npm install anyamount
- runtime
- Node 18+, every modern browser, Deno, Bun, edge runtimes.
- docs
- anyfamily.site/docs/anyamount
- playground
- run the family on StackBlitz
why
toFixed and hand-placed separators break outside en-US; numeral.js is 20 kB and English-first. anyamount is one call over the formatter the runtime already has — any currency, any sanctioned unit, bigint — plus parse() for the input field, the direction Intl never covered.
usage
anyamount(1234567) // "1.2M"
anyamount(1999, { mode: "currency", currency: "EUR" }) // "€1,999.00"
anyamount(3.2, { mode: "unit", unit: "gigabyte" }) // "3.2 GB"
anyamount(1234, { compact: true }) // "1.2K" — badges; compact: false never abbreviates
anyamount.range(10, 20, { mode: "currency", currency: "EUR" }) // "€10.00 – 20.00"
anyamount.parse("1.999,50", { locale: "de" }) // 1999.5 — NaN when it is not a number
anyamount.symbol("USD") // "$"not for
Money arithmetic, exchange rates, decimal precision — do the maths in minor units or a decimal library, then format the result here.