Course contentsShow
← JavaScript
Lesson 2238 of 2,72346. InternationalizationFree lesson

Intl.ListFormat: Formatting Lists in Natural Language

Learn how Intl.ListFormat creates localized conjunctions and disjunctions for arrays of items.

Intl.ListFormat: Formatting Lists in Natural Language

You'll learn how to automatically format arrays of items as natural-language lists with proper conjunctions ("and", "or") that adapt to any locale.

The Core Idea

When displaying lists to users, different languages use different conjunctions and punctuation. English joins items with commas and "and" ("apples, oranges, and bananas"), but other languages have their own conventions. Intl.ListFormat handles this complexity automatically, creating grammatically correct lists for any locale.

Think of it like a translator for list formatting—you provide an array, and it returns a culturally appropriate string.

Creating a ListFormat Instance

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

const items = ['apples', 'oranges', 'bananas'];
console.log(formatter.format(items));
// "apples, oranges, and bananas"

The type Option

Control whether items are joined or separated:

  • 'conjunction': Joins items with "and" (default)
  • 'disjunction': Separates items with "or"
const orFormatter = new Intl.ListFormat('en', { type: 'disjunction' });
console.log(orFormatter.format(['red', 'green', 'blue']));
// "red, green, or blue"

The style Option

  • 'long': Full words ("apples, oranges, and bananas")
  • 'short': Abbreviated ("apples, oranges, & bananas")
  • 'narrow': Most compact ("apples, oranges, bananas")

Locale Variations

const spanishList = new Intl.ListFormat('es').format(['uno', 'dos', 'tres']);
console.log(spanishList);
// "uno, dos y tres" (notice "y" instead of "and")

Key Takeaway: Intl.ListFormat transforms arrays into grammatically correct, locale-appropriate lists using conjunction ("and") or disjunction ("or"), with style options controlling verbosity—eliminating the need for manual list formatting logic.