JavaScript Intl

Beginner
8 min read
Updated: Nov 2026
3 examples
Internationalization

Definition and Usage

Intl is a built-in JavaScript object for internationalization: formatting dates, numbers, lists and relative times, comparing strings, naming languages and regions, and working with locale tags. You do not import it. You call constructors such as new Intl.NumberFormat() or static helpers such as Intl.getCanonicalLocales().

Each formatter takes a locale (for example "en-US" or "de-DE") and options, then turns data into text that matches that language and region. That is better than building strings by hand with commas and currency symbols.

This page explains the idea. The Intl Methods index links the full guides for every helper and constructor in this series.

Intl is not a constructor.

You never write new Intl(). Intl is a namespace object, like Math. You use its constructors and static methods, such as new Intl.DateTimeFormat() and Intl.getCanonicalLocales().

JavaScript Syntax

Create a formatter with a locale, then call format:

JavaScript
const price = new Intl.NumberFormat("en-US", {
  style: "currency",
  currency: "USD"
});
console.log(price.format(19.99));

const d = new Date(Date.UTC(2024, 5, 15, 12, 0, 0));
console.log(new Intl.DateTimeFormat("en-US", { timeZone: "UTC" }).format(d));

Core Ideas

Ideas every Intl tutorial in this series builds on:

IdeaExampleRemember
IntlIntl.NumberFormatThe built-in namespace for locale APIs. You do not create it
Locale tag"en-US" or "de-DE"A BCP 47 language tag that picks language and region
Formatternew Intl.DateTimeFormat()An object that turns data into locale text
options{ style: "currency" }Settings that change how format() looks
Canonical tagIntl.getCanonicalLocales()Normalized locale strings
Plural categoryPluralRules.select(1)Names like one or other used to pick message text
Feature guardtypeof Intl.SegmenterCheck before using newer Intl APIs

Hand-built Strings vs Intl

You can build labels yourself, but Intl knows locale rules:

TaskHand-built ideaIntl way
Money"$" + nnew Intl.NumberFormat("en-US", { style: "currency", currency: "USD" })
Datepad month/day yourselfnew Intl.DateTimeFormat("en-US", { timeZone: "UTC" })
Lista + ", " + bnew Intl.ListFormat("en").format([a, b])
Sort namesa < bnew Intl.Collator("en").compare
Relative timecustom "days ago"new Intl.RelativeTimeFormat("en").format(-3, "day")
Clean tagsmanual lower-casingIntl.getCanonicalLocales(tags)

Use Intl whenever the output must follow a language or region. Keep hand-built strings for fixed technical labels that never change by locale.

How Intl Works

Pick a locale

Pass a tag such as "en-US" or a list of tags. The engine chooses the best available locale.

Create a formatter

Most tools are constructors: new Intl.NumberFormat(), new Intl.DateTimeFormat(), and so on.

Call format (or compare)

Feed data into format, compare, select or of depending on the API.

Reuse the object

Build one formatter and call it many times. That keeps code clear and avoids recreating options.

Guard new APIs

Some members are newer (Segmenter, DurationFormat, supportedValuesOf). Check typeof before using them.

Real-Life Uses

Intl solves everyday UI text problems. Common uses:

UseHow Intl helps
Prices and statsShow numbers and currencies the way readers expect for their locale.
Dates and schedulesFormat calendar days and clock times with a chosen time zone.
Sorted labelsSort names and titles with Collator instead of raw code-point order.
Friendly lists and relative timesBuild "A, B, and C" or "3 days ago" without hard-coding English only.

JavaScript Examples

Three short programs. Each one prints plain text that is the same every time you run it.

Example 1 — A Quick Tour of Intl

Format a number, a UTC date and a short list with three Intl constructors.

JavaScript
const d = new Date(Date.UTC(2024, 5, 15, 12, 0, 0));

console.log("Price: " + new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(19.99));
console.log("Date: " + new Intl.DateTimeFormat("en-US", { timeZone: "UTC" }).format(d));
console.log("List: " + new Intl.ListFormat("en").format(["A", "B", "C"]));

How It Works

  1. NumberFormat. Currency style turns 19.99 into a dollar amount.
  2. DateTimeFormat. UTC keeps the calendar day stable on every machine.
  3. ListFormat. English conjunction style inserts commas and "and".

Example 2 — Same Value, Two Locales

One number and one date look different in en-US and de-DE.

JavaScript
const n = 1234567.89;
const d = new Date(Date.UTC(2024, 5, 15, 12, 0, 0));
const utc = { timeZone: "UTC" };

console.log("US number: " + new Intl.NumberFormat("en-US").format(n));
console.log("DE number: " + new Intl.NumberFormat("de-DE").format(n));
console.log("US date: " + new Intl.DateTimeFormat("en-US", utc).format(d));
console.log("DE date: " + new Intl.DateTimeFormat("de-DE", utc).format(d));

How It Works

  1. Separators differ. US and German number formats swap grouping and decimal marks.
  2. Date order differs. US prints month/day/year; German prints day.month.year.
  3. Same inputs. Only the locale argument changes.

Example 3 — Clean Tags and Compare Strings

Normalize locale tags and sort names with Collator.

JavaScript
const tags = Intl.getCanonicalLocales(["EN-us", "fr-FR"]);
const names = ["Zoe", "anne", "Bob"].sort(new Intl.Collator("en").compare);

console.log("Tags: " + tags.join(", "));
console.log("Names: " + names.join(", "));
Collator tutorial

How It Works

  1. Canonical tags. Mixed-case input becomes standard BCP 47 tags.
  2. Locale sort. Collator orders names with English rules.
  3. Ready for formatters. Clean tags can be passed into other Intl constructors.

Intl Methods

This series covers 12 Intl APIs. Each one has its own tutorial:

MethodWhat it does
getCanonicalLocales()Normalize locale tags to canonical BCP 47 form.
supportedValuesOf()List supported calendars, currencies, time zones and more.
CollatorCompare and sort strings with locale rules.
DateTimeFormatFormat dates and times for a locale and time zone.
DisplayNamesTurn language, region and currency codes into names.
DurationFormatFormat duration objects such as hours and minutes.
ListFormatJoin arrays into locale lists with and / or.
LocaleParse a tag into language, region and script.
NumberFormatFormat numbers, currencies and percents.
PluralRulesSelect plural categories such as one and other.
RelativeTimeFormatFormat phrases like 3 days ago.
SegmenterSplit text into graphemes, words or sentences.

Full list: Intl Methods index.

Frequently Asked Questions

Intl is a built-in object with constructors and static methods for locale-aware formatting, collation, plural rules and locale tag helpers.
No. Intl is a global object in browsers and in Node.js. You call it directly.
A BCP 47 string such as en-US or de-DE that names a language and often a region. Formatters use it to pick wording and separators.
Newer ones such as Segmenter, DurationFormat, supportedValuesOf, DisplayNames, ListFormat, RelativeTimeFormat and Locale may be missing on older engines. Check typeof before use.
Start with NumberFormat and DateTimeFormat for everyday UI text, then read Collator and ListFormat. Use the methods index to jump to a specific API.

Ready for the method guides?

Open the Intl Methods index to learn every helper and formatter with syntax, runnable examples and FAQs.

Intl Methods index →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

15 people found this page helpful