Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Intl.ListFormat — locale-aware list formatting

Intl.ListFormat combines string list elements using locale-appropriate separators and conjunctions. format() returns text, while formatToParts() separates the original elements from the inserted connecting text.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

new Intl.ListFormat(locales?, options?).format(list)

Intl.ListFormat is an internationalization API defined by ECMA-402, not a DOM API. Create a formatter with new Intl.ListFormat(locales, options). The locales argument selects preferred locales; omitting it uses the environment's default locale.

The type option accepts "conjunction" (“and”-style joining, the default), "disjunction" (“or”-style alternatives), or "unit" (a list of units). The style option accepts "long" (the default), "short", or "narrow". The formatter neither translates elements nor formats the numbers or units themselves.

format(list) accepts an iterable containing only strings; an element of another type causes a TypeError. An empty list produces "". formatToParts(list) returns objects with type and value fields: "element" identifies an input element and "literal" identifies inserted connecting text. This lets you highlight elements without parsing punctuation.

Exact connecting text depends on the implementation's locale data; do not assume identical text across environments. Check Intl.ListFormat availability in the target environment—its presence in Node does not prove browser support. The example checks element preservation and reconstruction of the result, not a particular separator.

Examples

const formatter = new Intl.ListFormat("en", {
  type: "conjunction",
  style: "long"
});
const items = ["Ada", "Lin", "Sam"];
const parts = formatter.formatToParts(items);
console.log(JSON.stringify(parts.filter(p => p.type === "element").map(p => p.value)));
console.log(parts.map(p => p.value).join("") === formatter.format(items));

Result

["Ada","Lin","Sam"]
true

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources