How to format international currencies in Javascript

Under Review
Mark O'Neill
March 26, 2021

Show currencies and other numbers in the correct format by using the ECMAScript Internationalization API (Intl). This API also provides options for string comparison, number formatting, and date and time formatting.

copy code
export formatCurrency = (value, locale, currency) => {
  return new Intl.NumberFormat(locale, {
    style: "currency",
    currency: currency,
    maximumFractionDigits: 2

const number = 123456.789

console.log(formatCurrency(number, 'de-DE', 'EUR'))
// Output: "123.456,79 €"

console.log(formatCurrency(number, 'ja-JP', 'JPY'))
// Output: "¥123,457"

Related links

Know a better answer? Join our our community and let us know.