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
Intlobject 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. UsePluralRules.select(n)to choose the right message form. numeric: "auto"onRelativeTimeFormatproduces idiomatic words (yesterday,next week).Intl.Collatorwithnumeric: truesortsa2beforea10(natural sort).
The live demo below uses these exact constructors on your machine, so its output reflects your runtime’s locale support.