JavaScript Intl API Reference

Intl.DateTimeFormat, NumberFormat, PluralRules, Collator options reference

Searchable reference for the JavaScript Intl API — DateTimeFormat, NumberFormat, RelativeTimeFormat, ListFormat, PluralRules and Collator — with a live formatter that runs each constructor in your browser for any locale and options.

What is the difference between Intl.NumberFormat styles?

The style option selects what is formatted: 'decimal' for plain numbers, 'currency' (requires a currency code) for money, 'percent' which multiplies by 100 and adds a percent sign, and 'unit' (requires a unit) for measurements like kilometers. Each respects the locale's grouping and decimal separators.

The Intl namespace provides locale-aware formatting and comparison built into JavaScript. This reference lists the main constructors and runs them live in your browser so you can see real output.

How it works

Each Intl constructor takes a locale (a BCP 47 tag like en-US, de-DE, ar-EG) and an options object, then exposes a .format() (or .compare(), .select()) method:

new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(1234.5);
// → "1.234,50 €"

new Intl.RelativeTimeFormat("en", { numeric: "auto" }).format(-1, "day");
// → "yesterday"

new Intl.PluralRules("ar-EG").select(3);
// → "few"

Locale data ships with the engine, so the same code adapts grouping separators, decimal marks, currency placement, plural categories and collation order per language automatically.

Tips and notes

  • Reuse formatters. Constructing an Intl object is expensive (it loads locale data); calling .format() is cheap. Build once, format many.
  • Plural categories are language-specific. Don’t assume one/other — Arabic has six. Use PluralRules.select(n) to choose the right message form.
  • numeric: "auto" on RelativeTimeFormat produces idiomatic words (yesterday, next week).
  • Intl.Collator with numeric: true sorts a2 before a10 (natural sort).

The live demo below uses these exact constructors on your machine, so its output reflects your runtime’s locale support.