The UI/UX lesson "Internationalization (i18n)" already used NumberFormat, DateTimeFormat and PluralRules for Mrs. Sri's card. Those are only three members of the Intl family, JavaScript's set of built-in formatters for numbers, money, dates, relative times, plurals, lists, alphabetical order, language names and text splitting, all following a locale. Here we take all of them apart. They work like the Mist Homestay receptionist who knows every country's habits by heart: hand her a number, a date or a list of rooms plus the guest's locale, and she writes it the way that guest expects. What she knows comes from one big book, CLDR (the Unicode Common Locale Data Repository), which every browser carries through the ICU library. Each browser carries a different edition, so the answers sometimes differ a little, and we measure those differences too.
One pattern for every formatter
const money = new Intl.NumberFormat('ja-JP', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 });
money.format(70); // "$70"
money.formatToParts(70); // [{ type: "currency", value: "$" }, { type: "integer", value: "70" }]
money.resolvedOptions().locale; // "ja-JP"
- The constructor takes a locale (one tag or a list of tags) and options, and returns a formatter. Create it once, use it many times.
format()gives the finished text.formatToParts()gives its pieces, handy when you want to make the number bold yourself.resolvedOptions()tells you what was really used: the locale, the numbering system, the number of decimals, the time zone, the calendar.Intl.NumberFormatis the API for formatting numbers by locale.(70).toLocaleString('en-US', options)is only a shortcut that builds the same formatter on every call.
When the browser has no data for the locale you asked for, it quietly switches to another one. Mrs. Sri wants a Javanese version (jv): new Intl.NumberFormat('jv').resolvedOptions().locale gives "jv" in Firefox 146, Safari 26.4 and Node 22.22.1, but "en-US" in Chromium 147, because Chrome doesn't ship Javanese data and falls back to the browser's default language. Give a fallback list: with ['jv', 'id'], Chrome picks "id" and writes "Sabtu, 12 Desember 2026".
NumberFormat: how many decimals does the rupiah have?
Mrs. Sri's prices are in US dollars, and the dollar has 2 decimals in every engine. Not every currency is that simple. We ran the same code for the Indonesian rupiah (IDR), the currency of the id-ID locale. It ran in three browser engines (through Playwright) and in Node 22.22.1, which carries ICU 78.2 with CLDR 48:
| Code | Chromium 147 | Firefox 146 | WebKit 26.4 (Safari) | Node 22.22.1 |
|---|---|---|---|---|
new Intl.NumberFormat('id-ID', { style: 'currency', currency: 'IDR' }).format(700000) |
Rp 700.000,00 | Rp 700.000,00 | Rp700.000,00 | Rp 700.000 |
.resolvedOptions().maximumFractionDigits for IDR |
2 | 2 | 2 | 0 |
the same, plus maximumFractionDigits: 0 |
Rp 700.000 | Rp 700.000 | Rp700.000 | Rp 700.000 |
new Intl.NumberFormat('ja-JP', { style: 'currency', currency: 'JPY' }).format(9800) |
¥9,800 | ¥9,800 | ¥9,800 | ¥9,800 |
new Intl.NumberFormat('ar-EG', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(70) |
٧٠ US$ | ٧٠ US$ | ٧٠ US$ | ٧٠ US$ |
Each currency's number of decimals comes from data. The ISO 4217 table lists the rupiah with 2 decimals. CLDR said 2 as well up to CLDR 47, then CLDR 48 (October 2025) changed IDR to 0 decimals. V8, the JavaScript engine of Chrome and Node, takes decimals from the CLDR inside its ICU: Node 22.22.1 already carries CLDR 48, so 0; Chromium 147 still gives 2, while Chromium 156 already gives 0. Firefox and Safari use the ISO 4217 table, so 2. The result: different, even though the code is identical.
The rule: for rupiah, always say maximumFractionDigits: 0, so every engine stops at 0 decimals. More from the table:
- Safari puts no space after "Rp"; the other engines put a no-break space U+00A0. The yen in
ja-JPuses the wide ¥ (U+FFE5), except Safari, which uses the plain ¥ (U+00A5). ar-EGuses the digits ٠ to ٩, the thousands separator ٬, and starts with the invisible mark U+200F (right-to-left mark) so the number doesn't flip in the middle of Arabic text.notation: 'compact'writes 700000 as "700K" (en-US), "700 rb" (id-ID), "70万" (ja-JP, where 万 = 10,000) and "٧٠٠ ألف" (ar-EG).currencyDisplay: 'narrowSymbol'inid-IDgives "$70" instead of "US$70" for Mrs. Sri's US dollars.
DateTimeFormat and timeZone
Mrs. Sri's check-in: Saturday, 12 December 2026, at 14:00 in the homestay's time zone (Asia/Singapore), which is 06:00 UTC.
const checkIn = new Date('2026-12-12T06:00:00Z');
const opts = { dateStyle: 'full', timeStyle: 'short', timeZone: 'Asia/Singapore' };
new Intl.DateTimeFormat('en-US', opts).format(checkIn); // "Saturday, December 12, 2026 at 2:00 PM"
new Intl.DateTimeFormat('id-ID', opts).format(checkIn); // "Sabtu, 12 Desember 2026 pukul 14.00"
new Intl.DateTimeFormat('ja-JP', opts).format(checkIn); // "2026年12月12日土曜日 14:00"
new Intl.DateTimeFormat('ar-EG', opts).format(checkIn); // "السبت، ١٢ ديسمبر ٢٠٢٦ في ٢:٠٠ م"
new Intl.DateTimeFormat('en-US', { dateStyle: 'long', timeZone: 'Asia/Singapore' }).format(checkIn); // "December 12, 2026"
dateStyleandtimeStyletake'full','long','medium'or'short'. A full date in English:new Intl.DateTimeFormat('en-US', { dateStyle: 'long' }).format(date).- Safari differs slightly: "2026年12月12日 土曜日 14:00" (with a space), and for
ar-EGit puts a comma after the month. timeZonedecides which clock time is written. ADateis one point in time; withouttimeZone, the time is written in the guest's device zone. A guest's laptop in Tokyo would write 15:00, while check-in is at 14:00 at the homestay. So alwaystimeZone: 'Asia/Singapore'. WithtimeZoneName: 'short',en-USwrites "02:00 PM GMT+8", andja-JPwithtimeZone: 'Asia/Tokyo'writes "15:00 JST".timeZoneNamecannot be added to theoptsabove, because it cannot be combined withdateStyleortimeStyle(Node 24 and Chromium:TypeError: Invalid option : option). Write the time by parts:{ hour: '2-digit', minute: '2-digit', timeZone: 'Asia/Singapore', timeZoneName: 'short' }.- The calendar follows the locale. Safari writes
ar-SAin the Hijri calendar: "٣ رجب، ١٤٤٨ هـ", andresolvedOptions().calendargives"islamic-umalqura". Lock the calendar withcalendar: 'gregory'or the tagar-SA-u-ca-gregory.
RelativeTimeFormat, PluralRules, ListFormat
const rtf = new Intl.RelativeTimeFormat('en-US', { numeric: 'auto' });
rtf.format(3, 'day'); // "in 3 days"
rtf.format(1, 'day'); // "tomorrow"
rtf.format(-1, 'day'); // "yesterday"
RelativeTimeFormatonly writes the difference; working out "3 days from now" is still your job. The 3-day free cancellation limit becomes "dalam 3 hari" (id-ID), "3 日後" (ja-JP) and "خلال ٣ أيام" (ar-EG).numeric: 'auto'picks words like "tomorrow" and "yesterday"; without it, you get "in 1 day".PluralRulespicks the plural category.resolvedOptions().pluralCategories:idonlyother,enone, other,jaonlyother,arzero, one, two, few, many, other. Forar-EG: 0 zero, 1 one, 2 two, 3 to 10 few, 11 to 99 many, 100 to 102 other, 103 few again.new Intl.PluralRules('en-US', { type: 'ordinal' })for positions: 1 one (1st), 2 two (2nd), 3 few (3rd), 4 other (4th), 11 other (11th), 21 one (21st).ListFormatjoins the list of rooms: "Terrace Room, Attic Room, and Garden Room" (en-US), "Terrace Room, Attic Room, dan Garden Room" (id-ID), "Terrace Room、Attic Room、Garden Room" (ja-JP). Withtype: 'disjunction'the joining word is "or" ("atau" inid-ID).
Collator, DisplayNames, Segmenter
const guests = ['Zahra', 'Ömer', 'Oscar', 'andi', 'Mrs. Sri', 'Émile'];
[...guests].sort(); // ["Mrs. Sri", "Oscar", "Zahra", "andi", "Émile", "Ömer"]
[...guests].sort(new Intl.Collator('en').compare); // ["andi", "Émile", "Mrs. Sri", "Ömer", "Oscar", "Zahra"]
[...guests].sort(new Intl.Collator('sv').compare); // ["andi", "Émile", "Mrs. Sri", "Oscar", "Zahra", "Ömer"]
const rooms = ['Room 10', 'Room 2', 'Room 1'];
rooms.sort(new Intl.Collator('en', { numeric: true }).compare); // ["Room 1", "Room 2", "Room 10"]
sort()without a compare function orders UTF-16 code units: capitals before lowercase, accented letters after z.Intl.Collatorsorts like that language's dictionary; Swedish really does put Ö after Z.numeric: truereads numbers as numbers.DisplayNamesgives the names of languages, regions and currencies. A language menu should write each language in that language:new Intl.DisplayNames(['ja'], { type: 'language' }).of('ja')gives "日本語", forar"العربية", forid"Indonesia". In English,of('ar-EG')gives "Arabic (Egypt)", andtype: 'currency'for USD gives "US Dollar".Segmentersplits text by grapheme, word or sentence. Japanese uses no spaces:'チェックインの3日前までキャンセル無料。'.split(' ')gives only 1 piece.new Intl.Segmenter('ja', { granularity: 'word' })gives the words チェックイン, の, 3, 日前, まで, キャンセル, 無料 (theisWordLikeones).
📌 How the engines differ, measured
Every result above is the same in the four engines, except the ones in this table:
| Measured | Chromium 147 | Firefox 146 | WebKit 26.4 | Node 22.22.1 |
|---|---|---|---|---|
| Default IDR decimals | 2 | 2 | 2 | 0 |
After "Rp" in id-ID |
U+00A0 | U+00A0 | nothing | U+00A0 |
JPY symbol in ja-JP |
¥ | ¥ | ¥ | ¥ |
ar-SA calendar |
gregory | gregory | islamic-umalqura | gregory |
Javanese data (jv) |
none, falls back to en-US | yes | yes | yes |
The "3" in a ja word Segmenter |
isWordLike | isWordLike | not isWordLike | isWordLike |
ListFormat ar-EG |
plain | plain | each item wrapped in U+2068 and U+2069 | plain |
The versions: Chromium 147.0.7727.15, Firefox 146.0.1 and WebKit 26.4 from Playwright, and Node 22.22.1 with ICU 78.2, CLDR 48 and Unicode 17.0. We measured again on 29 October 2026 with Chromium 156.0.8078.4 and Firefox 148.0.2 from Playwright: Firefox 148 matches the Firefox 146 column exactly, and Chromium 156 differs in one row only, the default IDR decimals, which are now 0 as in Node. The Lab runs the same code in your browser and puts this table next to it.
⚠️ When Intl output catches you out
- Comparing Intl output with typed text. There are invisible U+00A0, U+202F and U+200F characters. Compare against Intl output too, or use
formatToParts(). - Relying on a currency's default decimals. IDR can be 2 or 0 depending on the engine. Say
maximumFractionDigits. - No
timeZone. The check-in time follows the guest's device zone. Name the zone where it happens. - An unsupported locale. The result quietly uses another locale. Check
resolvedOptions().localeand give a fallback list such as['jv', 'id'].
TL;DR: Intl formats by locale with the CLDR data each browser carries through ICU. The pattern is always the same: new Intl.X(locale, options), then format(), formatToParts(), and resolvedOptions() to see what was really used; toLocaleString is only a shortcut to Intl.NumberFormat. NumberFormat: the default IDR decimals are 2 in Chrome 147, Firefox 146 and Safari 26.4 but 0 in Node 22.22.1 (CLDR 48) and Chrome 156, so say maximumFractionDigits: 0. DateTimeFormat: dateStyle: 'long' for "December 12, 2026", always with timeZone: 'Asia/Singapore'; Safari uses the Hijri calendar for ar-SA. RelativeTimeFormat writes "in 3 days", PluralRules picks the category (ar has six), ListFormat joins lists, Collator sorts like a dictionary (and numeric: true puts "Room 2" before "Room 10"), DisplayNames writes "日本語" and "العربية", Segmenter splits Japanese text that has no spaces. Chrome 147 has no Javanese data, so check resolvedOptions().locale.
⚡ One pattern for every formatter
Write:
const money = new Intl.NumberFormat('ja-JP', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 });
money.format(70); // "$70"
money.resolvedOptions().locale; // "ja-JP"
Meaning: The constructor takes a locale and options, and you create it once and use it many times. format() gives the finished text, resolvedOptions() tells you what was really used.
⚡ How many decimals does the rupiah have?
Guess first: does new Intl.NumberFormat('id-ID', { style: 'currency', currency: 'IDR' }).format(700000), the Indonesian rupiah in the id-ID locale, give the same result in Chromium 147 and in Node 22.22.1?
No. Chromium 147 writes Rp 700.000,00, Node 22.22.1 writes Rp 700.000. The number of IDR decimals comes from the data each engine carries.
Meaning: Identical code can give different results. For rupiah, always say maximumFractionDigits: 0, so every engine stops at 0 decimals.
⚡ A date in English, on the homestay's clock
Write:
new Intl.DateTimeFormat('en-US', { dateStyle: 'long', timeZone: 'Asia/Singapore' }).format(checkIn); // "December 12, 2026"
Meaning: dateStyle: 'long' writes the full date in the locale's language. timeZone decides which clock time is written: without it, a guest's laptop in Tokyo writes 15:00, while check-in is at 14:00 at the homestay.