Make Currency

Format, display and parse monetary values in JavaScript with support for 139 currencies and locale-aware formatting powered by Intl.NumberFormat.
Installing
Using npm:
npm install make-currency
Using yarn:
yarn add make-currency
Using jsDelivr CDN:
<script src="https://cdn.jsdelivr.net/npm/make-currency/dist/make.min.js"></script>
Using unpkg CDN:
<script src="https://unpkg.com/make-currency/dist/make.min.js"></script>
Demo
Click here
currency(floatValue, options?)
Formats a numeric value into a locale-aware currency string.
import { currency, TYPES } from 'make-currency'
// Default (USD)
currency(1234.56) // "$1,234.56"
// Without symbol
currency(1234.56, { symbol: false }) // "1,234.56"
// With a specific currency
currency(1234.56, { money: TYPES.BRL }) // "R$ 1.234,56"
currency(1234.56, { symbol: false, money: TYPES.BRL }) // "1.234,56"
// Empty string when value is zero
currency(0, { isEmpty: true }) // ""
currency(0, { isEmpty: false }) // "$0.00"
Options
| Option | Type | Default | Description |
|---|
symbol | boolean | true | Include the currency symbol in the output |
isEmpty | boolean | false | Return "" when the value is 0 |
money | TExchange | USD | Currency configuration (locale + code + transforms) |
Signature
function currency(
floatValue: number,
options?: TCurrencyOptions | 'INPUT'
): string
Pass 'INPUT' as options to use the global currency (CONFIGURE) with symbol: false and isEmpty: true — ideal for controlled input components.
currencyFn(value, options?)
Parses a formatted currency string (e.g. from an input field) and returns both its numeric and formatted representations. Useful for building real-time currency inputs.
import { currencyFn } from 'make-currency'
currencyFn('123456')
// { floatValue: 1234.56, stringValue: '1,234.56' }
currencyFn('1')
// { floatValue: 0.01, stringValue: '0.01' }
currencyFn('')
// { floatValue: 0, stringValue: '' }
Return type
interface TCurrency {
floatValue: number // The numeric value (e.g. 1234.56)
stringValue: string // The formatted string without symbol (e.g. '1,234.56')
}
Options
Same as currency() — symbol, isEmpty, and money. Defaults to symbol: false and isEmpty: true.
CONFIGURE({ money })
Sets the global default currency used by currency() and currencyFn() when no money option is provided.
import { CONFIGURE, TYPES, currency, currencyFn } from 'make-currency'
// Set BRL as the global currency
CONFIGURE({ money: TYPES.BRL })
// Now all calls without `money` use BRL
currency(1234.56) // "R$ 1.234,56"
currencyFn('123456') // { floatValue: 1234.56, stringValue: '1.234,56' }
The default is USD if CONFIGURE is never called.
Display currency values
How digits typed into an input field map to the formatted output (example using BRL):
| Typed | Input value | Float value | String value |
|---|
| 0,00 | 0.00 | 0,00 |
| 1 | 0,01 | 0.01 | 0,01 |
| 12 | 0,12 | 0.12 | 0,12 |
| 123 | 1,23 | 1.23 | 1,23 |
| 1234 | 12,34 | 12.34 | 12,34 |
| 12345 | 123,45 | 123.45 | 123,45 |
| 123456 | 1.234,56 | 1234.56 | 1.234,56 |
| 1234567 | 12.345,67 | 12345.67 | 12.345,67 |
| 12345678 | 123.456,78 | 123456.78 | 123.456,78 |
| 123456789 | 1.234.567,89 | 1234567.89 | 1.234.567,89 |
Supported Currencies
| # | Code | Symbol | Currency | Locale |
|---|
| 1 | AED | د.إ | Dirham dos Emirados Árabes Unidos | ar-AE |
| 2 | ALL | L | Lek albanês | sq-AL |
| 3 | AMD | ֏ | Dram armênio | hy-AM |
| 4 | ANG | ƒ | Florim das Antilhas Holandesas | nl-NL |
| 5 | AOA | Kz | Kwanza angolano | pt-AO |
| 6 | ARS | $ | Peso argentino | es-AR |
| 7 | AUD | $ | Dólar australiano | en-AU |
| 8 | AWG | Afl. | Florim arubano | nl-AW |
| 9 | AZN | ₼ | Manat azeri | az-AZ |
| 10 | BAM | KM | Marco bósnio-herzegovino | bs-BA |
| 11 | BBD | $ | Dólar barbadense | en-BB |
| 12 | BDT |