0Pricing
JavaScript Academy · Lesson

Formatting Numbers and Currency

Use Intl.NumberFormat for locale-aware numbers.

The Intl Namespace

Intl is the built-in JavaScript internationalization API. It formats numbers, dates, currencies, and more according to a locale's conventions — no library needed.

console.log(typeof Intl); // "object"
console.log(typeof Intl.NumberFormat); // "function"

Intl.NumberFormat Basics

Create a formatter with a locale, then call format(). Locales use BCP 47 tags like "en-US" or "de-DE".

const nf = new Intl.NumberFormat("en-US");
console.log(nf.format(1234567.89)); // "1,234,567.89"

All lessons in this course

  1. Formatting Numbers and Currency
  2. Formatting Dates and Times
  3. Relative Time and Plurals
  4. Locale-Aware Sorting
← Back to JavaScript Academy