Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JavaScript · Module

Intl

Intl is the namespace for JavaScript's ECMAScript Internationalization API. Its constructors and utilities provide locale-sensitive comparison, formatting, and other language-aware operations.

How it works

Intl is a namespace object for the ECMAScript Internationalization API. Its constructors and static utilities support locale-sensitive comparison, number formatting, date and time formatting, and other language-aware operations; it is used through its static members and constructors rather than called or instantiated itself.

Parameters

NameTypeDescription
localesstring | Intl.Locale | string[] | undefinedPreferred locale identifier, an Intl.Locale object, a locale list, or undefined to use the default locale.
optionsobject | undefinedAn object whose available properties depend on the constructor or function using it.

Key points

  • The namespace covers multiple internationalization features rather than one formatting operation.
  • Use its exposed static members directly; the namespace does not have instance methods.
  • Locale input selects the linguistic and regional conventions for an operation.
  • Locale negotiation chooses the best supported match instead of requiring every requested locale to be available.
  • A single locale may be represented by a BCP 47-style identifier or an Intl.Locale instance.
  • Multiple preferences can be supplied so the runtime can try fallback locales.

Common mistakes

  • Do not use new Intl(); the namespace itself cannot be constructed.
  • Calling Intl() or applying new to Intl throws instead of performing an operation.

Example: Locale-sensitive date and currency formatting

const locale = navigator.language;
const date = new Intl.DateTimeFormat(locale, {
  dateStyle: "medium",
}).format(new Date());
const amount = new Intl.NumberFormat(locale, {
  style: "currency",
  currency: "USD",
}).format(1234.5);
console.log(`${date}: ${amount}`);

The formatters use the browser's preferred locale to produce localized date and currency strings.

When to use it

Localized date and time display

Render dates and times according to a user's language and regional conventions.

Localized numeric output

Format prices, measurements, and quantities using locale-appropriate separators and patterns.

Locale-aware text comparison

Compare or sort user-facing text according to language-specific collation rules.

Locale negotiation and locale utilities

Inspect or normalize locale preferences before selecting an internationalized UI behavior.

Interview questions

QWhat is Intl in JavaScript?

Intl is a namespace object that groups the ECMAScript Internationalization API. It provides constructors and shared functionality for locale-sensitive tasks such as string comparison, number formatting, and date and time formatting.

Follow-up: How are requested locales handled? Constructors and language-sensitive methods negotiate the requested locale list against supported locales, using the localeMatcher option when applicable.

QCan Intl be called or instantiated directly?

Intl itself is not constructible or callable, and its members are static. Individual API objects, such as Intl.NumberFormat, are created through their own constructors.

Follow-up: What happens when no locale is supplied? The implementation uses its default locale, while an explicitly supplied locale or locale list expresses the preferred language or region.

QWhat are the common locales and options arguments?

The locales argument identifies the preferred locale for an operation. It can be omitted, supplied as one locale identifier or Intl.Locale object, or supplied as a list of locales; the implementation selects the closest supported locale.

Follow-up: What does options do? It is an object whose properties vary by constructor or function and can control formatting or locale negotiation behavior.

  • Intl.Collator
  • Intl.DateTimeFormat
  • Intl.DisplayNames
  • Intl.ListFormat
  • Intl.Locale
  • Intl.NumberFormat
  • Intl.PluralRules
  • Intl.RelativeTimeFormat

Source: Intl - JavaScript - MDN Web Docs - Mozilla. Checked 2026-10-15.