JavaScript Intl.ListFormat Object
Intl.ListFormat joins a list of strings into a readable phrase such as A, B, and C, using the right words and punctuation for each language.
Description
Intl.ListFormat turns an array of strings into a language-aware list. The type option chooses 'conjunction' ("A, B, and C"), 'disjunction' ("A, B, or C") or 'unit' ("5 lb, 12 oz"), and style can be 'long', 'short' or 'narrow'. It handles details like the Oxford comma in US English and the right word for "and" in each language, which a simple join() can't.
The formatToParts() method returns the list split into elements and literals, the words and punctuation between items, so you can wrap each item in its own markup, such as making each name a link. Formatters can be reused for many lists, which is faster than creating a new one each time.
Because the conjunctions, punctuation and ordering rules differ between languages, building lists with join(', ') and adding "and" yourself produces awkward results once a site is translated. Leaving it to Intl.ListFormat keeps lists natural in every language your users speak.
Creating
new Intl.ListFormat(locales, options)Example
Browser Support
The following information will show you the current browser support for the Intl.ListFormat object. Hover over a browser icon to see the version that first introduced support for this object.
Desktop





Tablets & Mobile





