JavaScript - JavaScript Internationalization API (Intl)

The JavaScript Internationalization API, commonly called the Intl API, is a built-in JavaScript feature used to create applications that work correctly for users from different countries, regions, and languages. It provides functionality for formatting numbers, currencies, dates, times, lists, relative time, and other locale-sensitive information.

For example, the number 1234567.89 can be displayed differently depending on the user's locale:

  • English (United States): 1,234,567.89

  • German (Germany): 1.234.567,89

  • Indian English: 12,34,567.89

Instead of manually creating these formats, JavaScript provides the Intl API to handle them according to international formatting rules.


1. What Is the Intl API?

Intl is a global JavaScript object that provides internationalization features.

The basic structure is:

Intl

It contains several constructors and methods for handling locale-sensitive operations.

Some commonly used features include:

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

These features are particularly useful when developing:

  • E-commerce websites

  • Banking applications

  • Travel applications

  • International websites

  • Multilingual applications

  • Financial dashboards

  • Date and calendar systems

  • Applications used across different countries


2. Understanding Locales

A locale describes the language and regional conventions used to format information.

For example:

"en-US"

means English as used in the United States.

Other examples include:

"en-IN"
"en-GB"
"de-DE"
"fr-FR"
"ja-JP"
"ar-SA"

The first part generally represents the language, while the second part represents the region.

For example:

en-IN

means English used in India.

en-US

means English used in the United States.

de-DE

means German used in Germany.

The locale can significantly affect how dates, numbers, currencies, and other values are displayed.


3. Formatting Numbers with Intl.NumberFormat

Intl.NumberFormat is used to format numbers according to a particular locale.

Example:

const number = 1234567.89;

const formatter = new Intl.NumberFormat("en-US");

console.log(formatter.format(number));

Output:

1,234,567.89

For Indian formatting:

const formatter = new Intl.NumberFormat("en-IN");

console.log(formatter.format(1234567.89));

Output:

12,34,567.89

The same JavaScript number is therefore displayed differently depending on the locale.


4. Formatting Currency

One of the most useful applications of Intl.NumberFormat is currency formatting.

Example:

const price = 2500;

const formatter = new Intl.NumberFormat("en-IN", {
    style: "currency",
    currency: "INR"
});

console.log(formatter.format(price));

Output:

₹2,500.00

For US dollars:

const formatter = new Intl.NumberFormat("en-US", {
    style: "currency",
    currency: "USD"
});

console.log(formatter.format(2500));

Output:

$2,500.00

For euros:

const formatter = new Intl.NumberFormat("de-DE", {
    style: "currency",
    currency: "EUR"
});

console.log(formatter.format(2500));

The formatting rules are automatically adjusted according to the specified locale.


5. Controlling Decimal Places

Intl.NumberFormat allows developers to control the number of decimal places.

Example:

const number = 1234.56789;

const formatter = new Intl.NumberFormat("en-US", {
    minimumFractionDigits: 2,
    maximumFractionDigits: 2
});

console.log(formatter.format(number));

Output:

1,234.57

Here:

minimumFractionDigits: 2

requires at least two decimal digits.

And:

maximumFractionDigits: 2

limits the number to two decimal digits.


6. Percentage Formatting

The Intl API can also format values as percentages.

Example:

const value = 0.75;

const formatter = new Intl.NumberFormat("en-US", {
    style: "percent"
});

console.log(formatter.format(value));

Output:

75%

Another example:

const discount = 0.25;

const formatter = new Intl.NumberFormat("en-IN", {
    style: "percent"
});

console.log(formatter.format(discount));

Output:

25%

The value 0.25 is interpreted as 25 percent.


7. Formatting Units

Modern JavaScript environments also support formatting measurement units.

Example:

const distance = 25;

const formatter = new Intl.NumberFormat("en-US", {
    style: "unit",
    unit: "kilometer"
});

console.log(formatter.format(distance));

Output:

25 km

Another example:

const weight = 50;

const formatter = new Intl.NumberFormat("en-US", {
    style: "unit",
    unit: "kilogram"
});

console.log(formatter.format(weight));

Output:

50 kg

This can be useful for applications involving:

  • Distance

  • Weight

  • Temperature

  • Speed

  • Digital storage

  • Other measurements


8. Formatting Dates with Intl.DateTimeFormat

Intl.DateTimeFormat is used to format dates and times according to a locale.

Example:

const date = new Date();

const formatter = new Intl.DateTimeFormat("en-US");

console.log(formatter.format(date));

The result will use the date conventions associated with the United States.

For India:

const formatter = new Intl.DateTimeFormat("en-IN");

console.log(formatter.format(date));

The output follows Indian date conventions.


9. Custom Date Formatting

You can specify exactly which date components should appear.

Example:

const date = new Date(2026, 8, 15);

const formatter = new Intl.DateTimeFormat("en-IN", {
    day: "numeric",
    month: "long",
    year: "numeric"
});

console.log(formatter.format(date));

A possible output is:

15 September 2026

The options include:

day
month
year
weekday
hour
minute
second

For example:

const formatter = new Intl.DateTimeFormat("en-IN", {
    weekday: "long",
    day: "numeric",
    month: "long",
    year: "numeric"
});

This can produce a result such as:

Tuesday, 15 September 2026

10. Formatting Time

Intl.DateTimeFormat can also format time.

Example:

const date = new Date();

const formatter = new Intl.DateTimeFormat("en-US", {
    hour: "numeric",
    minute: "numeric",
    second: "numeric"
});

console.log(formatter.format(date));

A possible result is:

9:45:30 PM

The same time can be represented differently depending on the locale.


11. Using a Specific Time Zone

Time zones are especially important in international applications.

Example:

const date = new Date();

const formatter = new Intl.DateTimeFormat("en-US", {
    timeZone: "Asia/Kolkata",
    dateStyle: "full",
    timeStyle: "long"
});

console.log(formatter.format(date));

Here:

timeZone: "Asia/Kolkata"

ensures that the time is displayed according to the India time zone.

Another example:

const formatter = new Intl.DateTimeFormat("en-US", {
    timeZone: "America/New_York",
    dateStyle: "full",
    timeStyle: "long"
});

This displays the same moment using New York's time zone.

This is useful for:

  • Flight booking systems

  • Online meetings

  • International business applications

  • Event management

  • Global e-commerce systems


12. Formatting Lists with Intl.ListFormat

Intl.ListFormat is used to format arrays as natural-language lists.

Example:

const items = ["Apple", "Banana", "Orange"];

const formatter = new Intl.ListFormat("en", {
    style: "long",
    type: "conjunction"
});

console.log(formatter.format(items));

Output:

Apple, Banana, and Orange

Instead of manually constructing the string, JavaScript handles the appropriate punctuation and conjunction.


13. Conjunction and Disjunction

A conjunction list generally uses the equivalent of "and".

Example:

const items = ["Tea", "Coffee", "Juice"];

const formatter = new Intl.ListFormat("en", {
    type: "conjunction"
});

console.log(formatter.format(items));

Output:

Tea, Coffee, and Juice

A disjunction uses the equivalent of "or".

const formatter = new Intl.ListFormat("en", {
    type: "disjunction"
});

console.log(formatter.format(items));

Output:

Tea, Coffee, or Juice

The appropriate language rules are applied according to the locale.


14. Relative Time with Intl.RelativeTimeFormat

Intl.RelativeTimeFormat is useful for displaying expressions such as:

  • Yesterday

  • Today

  • Tomorrow

  • 2 days ago

  • In 3 days

  • 5 minutes ago

  • In 2 hours

Example:

const formatter = new Intl.RelativeTimeFormat("en", {
    numeric: "auto"
});

console.log(formatter.format(-1, "day"));

Output:

yesterday

Another example:

console.log(formatter.format(2, "day"));

Output:

in 2 days

Without numeric: "auto":

const formatter = new Intl.RelativeTimeFormat("en");

console.log(formatter.format(-1, "day"));

The output may be:

1 day ago

This feature is commonly used in:

  • Social media

  • Messaging applications

  • News websites

  • Notification systems

  • Activity feeds


15. Plural Rules with Intl.PluralRules

Different languages have different pluralization rules.

For example:

1 item
2 items

JavaScript provides Intl.PluralRules to determine the appropriate plural category.

Example:

const rules = new Intl.PluralRules("en");

console.log(rules.select(1));

Output:

one

For:

console.log(rules.select(5));

Output:

other

This allows applications to choose appropriate text dynamically.

Example:

const count = 1;

const rules = new Intl.PluralRules("en");

if (rules.select(count) === "one") {
    console.log(`${count} item`);
} else {
    console.log(`${count} items`);
}

Output:

1 item

For count = 5:

5 items

16. Comparing Strings with Intl.Collator

Different languages have different rules for sorting and comparing text.

Intl.Collator provides locale-aware string comparison.

Example:

const collator = new Intl.Collator("en");

console.log(collator.compare("apple", "banana"));

The result is a negative number because "apple" comes before "banana".

It can also be used with sort():

const fruits = ["Banana", "Apple", "Orange"];

const collator = new Intl.Collator("en");

fruits.sort(collator.compare);

console.log(fruits);

Output:

["Apple", "Banana", "Orange"]

This is more appropriate for international applications than relying only on basic Unicode code-point ordering.


17. Intl.DisplayNames

Intl.DisplayNames can convert standardized codes into human-readable names.

For example, a country code can be converted into a country name.

const displayNames = new Intl.DisplayNames(["en"], {
    type: "region"
});

console.log(displayNames.of("IN"));

Output:

India

Another example:

console.log(displayNames.of("US"));

Output:

United States

It can also be used for certain language, currency, region, and other standardized identifiers.


18. Why the Intl API Is Important

Without the Intl API, developers might have to manually implement formatting rules.

For example, manually formatting Indian numbers could involve writing code to insert commas at specific positions.

That approach becomes complicated when supporting many countries.

The Intl API handles these differences automatically.

For example:

const number = 9876543.21;

console.log(
    new Intl.NumberFormat("en-IN").format(number)
);

console.log(
    new Intl.NumberFormat("en-US").format(number)
);

console.log(
    new Intl.NumberFormat("de-DE").format(number)
);

The same number can therefore be presented according to three different regional conventions.


19. Locale Negotiation

Sometimes an application supports several locales rather than specifying exactly one.

You can provide multiple locale options:

const formatter = new Intl.NumberFormat([
    "fr-CA",
    "fr-FR",
    "en-US"
]);

JavaScript attempts to select the best available locale.

This is useful when an application needs to adapt to the user's preferred language or region.


20. Browser Language Detection

Web applications can obtain the browser's preferred language through:

navigator.language

For example:

console.log(navigator.language);

A browser might return:

en-IN

The value can then be used with Intl.

const locale = navigator.language;

const formatter = new Intl.NumberFormat(locale);

console.log(formatter.format(1234567.89));

This allows the application to automatically adapt number formatting to the user's browser language.


21. Reusing Formatters

When formatting many values, it is better to create the formatter once and reuse it.

Instead of:

console.log(
    new Intl.NumberFormat("en-IN").format(1000)
);

console.log(
    new Intl.NumberFormat("en-IN").format(2500)
);

console.log(
    new Intl.NumberFormat("en-IN").format(5000)
);

Create one formatter:

const formatter = new Intl.NumberFormat("en-IN");

console.log(formatter.format(1000));
console.log(formatter.format(2500));
console.log(formatter.format(5000));

This makes the code cleaner and can avoid repeatedly constructing formatter objects.


22. Practical Example: E-Commerce Application

Consider an online shopping website serving customers in India.

Suppose a product costs:

const price = 12999.5;

We can format it as Indian currency:

const formatter = new Intl.NumberFormat("en-IN", {
    style: "currency",
    currency: "INR"
});

console.log(formatter.format(price));

Output:

₹12,999.50

The same application could support American customers:

const formatter = new Intl.NumberFormat("en-US", {
    style: "currency",
    currency: "USD"
});

The application can therefore present information appropriately for different markets.


23. Practical Example: International Event Application

Suppose an event occurs on a particular date and time:

const eventDate = new Date("2026-09-15T14:30:00Z");

The application can show the event in India's time zone:

const indiaFormatter = new Intl.DateTimeFormat("en-IN", {
    timeZone: "Asia/Kolkata",
    dateStyle: "medium",
    timeStyle: "short"
});

console.log(indiaFormatter.format(eventDate));

It can separately display the same event for users in another time zone by changing the timeZone option.

This prevents developers from having to manually calculate time-zone differences.


24. Advantages of the Intl API

The major advantages are:

Locale Awareness

It follows formatting conventions associated with different languages and regions.

Less Manual Code

Developers do not need to manually implement thousands of formatting rules.

Currency Support

Different currencies can be displayed using appropriate symbols and formatting.

Date and Time Support

Dates and times can be formatted according to regional conventions and time zones.

Language-Sensitive Sorting

Intl.Collator makes string comparison and sorting more appropriate for different languages.

Better User Experience

Users see information in a familiar format based on their language and region.

International Application Support

It makes it easier to build applications intended for users across multiple countries.


25. Important Intl Features to Remember

Feature Purpose
Intl.NumberFormat Formats numbers, currencies, percentages, and units
Intl.DateTimeFormat Formats dates and times
Intl.ListFormat Formats arrays as natural-language lists
Intl.RelativeTimeFormat Formats relative dates and times
Intl.PluralRules Determines plural categories
Intl.Collator Performs locale-aware string comparison
Intl.DisplayNames Converts standardized codes into localized names

26. Complete Example

The following example demonstrates several Intl features together:

const price = 15999.99;
const date = new Date();

const currencyFormatter = new Intl.NumberFormat("en-IN", {
    style: "currency",
    currency: "INR"
});

const dateFormatter = new Intl.DateTimeFormat("en-IN", {
    day: "numeric",
    month: "long",
    year: "numeric"
});

const listFormatter = new Intl.ListFormat("en", {
    type: "conjunction"
});

console.log("Price:", currencyFormatter.format(price));
console.log("Date:", dateFormatter.format(date));
console.log(
    "Products:",
    listFormatter.format(["Laptop", "Mouse", "Keyboard"])
);

This might produce output similar to:

Price: ₹15,999.99
Date: 15 September 2026
Products: Laptop, Mouse, and Keyboard

The exact output can vary depending on the environment and locale data available.


27. Conclusion

The JavaScript Internationalization API (Intl) provides standardized tools for creating applications that work naturally across different languages, countries, currencies, and time zones. Instead of manually implementing formatting rules, developers can use objects such as Intl.NumberFormat, Intl.DateTimeFormat, Intl.ListFormat, Intl.RelativeTimeFormat, Intl.PluralRules, and Intl.Collator.

For modern web applications, internationalization is especially important because users may access the same application from many different regions. Using the Intl API makes applications more accurate, maintainable, and user-friendly while reducing the amount of custom formatting code developers need to write.