Internationalization API in JavaScript

Introduction

The Intl namespace formats numbers, dates, currencies, and lists according to locale rules—so your app displays 1.234,56 € in Germany and $1,234.56 in the US without hand-written rules. You touched Intl.DateTimeFormat in dates; this chapter expands to numbers, plurals, and collation.

Prerequisites

Locales

A locale tag looks like en-US, zh-CN, fr-FR:

javascript
// Locale string controls formatting
const amount = 1234567.89;
 
console.log(new Intl.NumberFormat("en-US").format(amount));
console.log(new Intl.NumberFormat("de-DE").format(amount));

Use the user’s browser or app setting when possible:

javascript
const userLocale = navigator.language ?? "en-US";
console.log(new Intl.NumberFormat(userLocale).format(amount));

Currency Formatting

javascript
// style currency with ISO code
const price = 19.9;
 
const usd = new Intl.NumberFormat("en-US", {
  style: "currency",
  currency: "USD",
}).format(price);
 
const eur = new Intl.NumberFormat("de-DE", {
  style: "currency",
  currency: "EUR",
}).format(price);
 
console.log(usd, eur);

Intl.DateTimeFormat Recap

javascript
const date = new Date("2026-05-20T15:00:00Z");
 
const fmt = new Intl.DateTimeFormat("ja-JP", {
  dateStyle: "full",
  timeStyle: "short",
  timeZone: "Asia/Tokyo",
});
 
console.log(fmt.format(date));

Intl.RelativeTimeFormat

javascript
// "yesterday", "in 3 days" style labels
const rtf = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
 
console.log(rtf.format(-1, "day"));
console.log(rtf.format(3, "hour"));

Intl.PluralRules

javascript
// Choose word form for counts
const pr = new Intl.PluralRules("en");
const count = 1;
const rule = pr.select(count);
 
const messages = {
  one: "1 item",
  other: `${count} items`,
};
 
console.log(messages[rule] ?? messages.other);

Intl.Collator — Sort Strings

javascript
// Locale-aware sort
const names = ["Åsa", "Zoë", "Anna"];
const collator = new Intl.Collator("sv");
 
const sorted = [...names].sort(collator.compare);
console.log(sorted);

Mini Example: Format Cart Total

javascript
function formatCartTotal(cents, locale, currency) {
  const value = cents / 100;
  return new Intl.NumberFormat(locale, {
    style: "currency",
    currency,
  }).format(value);
}
 
console.log(formatCartTotal(1999, "en-US", "USD"));
console.log(formatCartTotal(1999, "fr-FR", "EUR"));

FAQ

Intl in Node?

Yes—Node ships ICU data; locale support depends on Node build (full ICU in production images).

Translate sentences?

Intl formats data—it does not replace i18n libraries (gettext, i18next) for full UI translation.

Fallback locale?

Try user locale, then en-US, or a product default.

What comes next?

CSS manipulation.