Currency formatter
What is a Currency Formatter?
The same amount is written very differently around the world. One thousand two hundred and thirty-four euros and fifty cents is €1,234.50 in Ireland, 1.234,50 € in Germany and 1 234,50 € in France. This formatter shows how a number looks in any locale and currency, using the same Intl.NumberFormat API your JavaScript code can use.
How to use it
- Enter the amount.
- Choose the locale, such as
en-US,de-DEorhi-IN. - Choose the ISO 4217 currency code, such as USD, EUR, INR or JPY.
- Copy the formatted result.
Examples for 1234567.891
en-US, USD: $1,234,567.89de-DE, EUR: 1.234.567,89 €en-IN, INR: ₹12,34,567.89 (Indian lakh grouping)ja-JP, JPY: ¥1,234,568 (yen has no minor unit)
The code
new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(1234.5)
// '1.234,50 €'Things to get right
- Locale and currency are independent. A US user viewing euro prices should see
€1,234.50, not the German format. - Decimal places vary by currency. JPY and KRW have 0, most have 2, and some like BHD have 3.
- Never use floating point for money calculations. Store amounts as integers in minor units (cents, paise) or use a decimal library, and format only for display.
- Accounting format shows negatives in parentheses: use
currencySign: 'accounting'.
Frequently Asked Questions
How do I format currency in JavaScript?
Use new Intl.NumberFormat(locale, { style: 'currency', currency: code }).format(amount).
Why does the yen have no decimal places?
The Japanese yen has no minor unit in everyday use, so ISO 4217 defines zero decimal places for JPY.
What is Indian number grouping?
In the en-IN locale, digits after the first thousand are grouped in twos, as in 12,34,567, matching lakhs and crores.
Should I store prices as floating-point numbers?
No. Store money as integers in the smallest unit or use a decimal type to avoid rounding errors.