No Login Data Private Local Save

Intl API Explorer - Online Format Numbers, Dates, Lists

7
0
0
0

Intl API Explorer

Explore JavaScript's Internationalization API — format numbers, dates, lists & more in real-time

en-US zh-CN ja-JP de-DE fr-FR ar-SA
1,234,567.89
const formatter = new Intl.NumberFormat('en-US', {
  style: 'decimal',
  notation: 'standard',
  minimumFractionDigits: 0,
  maximumFractionDigits: 2,
  signDisplay: 'auto',
  useGrouping: true
});
console.log(formatter.format(1234567.89)); // "1,234,567.89"
en-US zh-CN ja-JP de-DE ar-SA ko-KR

// Loading...
en-US zh-CN ja-JP es-ES fr-FR
apple, banana, cherry, and date
const formatter = new Intl.ListFormat('en-US', { type: 'conjunction', style: 'long' });
console.log(formatter.format(['apple', 'banana', 'cherry', 'date']));
en-US zh-CN ja-JP ko-KR es-ES
1 day ago
const formatter = new Intl.RelativeTimeFormat('en-US', { style: 'long', numeric: 'always' });
console.log(formatter.format(-1, 'day')); // "1 day ago"
en-US zh-CN ja-JP ru-RU ar-SA pl-PL
NumberCategory
const rules = new Intl.PluralRules('en-US', { type: 'cardinal' });
console.log(rules.select(1)); // "one"
en-US de-DE sv-SE zh-CN ar-SA
"apple" comes before "banana"
compare result: -1
const collator = new Intl.Collator('en-US', { usage: 'sort', sensitivity: 'variant' });
console.log(collator.compare('apple', 'banana')); // -1

Frequently Asked Questions

The Intl API (Internationalization API) is a built-in JavaScript API that provides language-sensitive formatting and comparison capabilities. It includes Intl.NumberFormat for formatting numbers and currencies, Intl.DateTimeFormat for dates and times, Intl.ListFormat for lists, Intl.RelativeTimeFormat for relative time expressions, Intl.PluralRules for pluralization, and Intl.Collator for locale-aware string comparison. It's supported in all modern browsers and Node.js.
The core Intl API is supported in all modern browsers including Chrome 24+, Firefox 29+, Safari 10+, Edge 12+, and Node.js 0.12+. Newer features like Intl.ListFormat (Chrome 72+), Intl.RelativeTimeFormat (Chrome 71+), and Intl.DisplayNames (Chrome 81+) have slightly different support timelines. Always check caniuse.com for the latest compatibility data.
BCP 47 (Best Current Practice 47) defines locale tags like en-US, zh-CN, or pt-BR. They consist of a language code (ISO 639-1, e.g., "en" for English) optionally followed by a region code (ISO 3166-1 alpha-2, e.g., "US" for United States). This allows the Intl API to provide region-specific formatting — for example, en-US formats dates as MM/DD/YYYY while en-GB uses DD/MM/YYYY.
Intl.NumberFormat uses ISO 4217 currency codes (like USD, EUR, JPY). When you specify a currency, it automatically places the currency symbol in the correct position for that locale — for example, de-DE with EUR shows "123,45 €" (symbol after the number with a space), while en-US with USD shows "$123.45" (symbol before the number). You can also control display with currencyDisplay: 'symbol' | 'narrowSymbol' | 'code' | 'name'.
dateStyle and timeStyle are high-level presets introduced in ECMAScript 2021. They let you specify 'full', 'long', 'medium', or 'short' and the browser picks the appropriate combination of weekday, year, month, day, hour, minute, and second for that locale. Individual components (like weekday: 'long') give you fine-grained control but require more configuration. You cannot use dateStyle/timeStyle together with individual component options — it's one or the other.
Different languages use different list patterns. In English, a conjunction list uses "A, B, and C" (Oxford comma is locale-dependent). In Spanish, it's "A, B y C" (no comma before "y"). In Japanese, it's "A、B、C" using ideographic commas without a final conjunction word. The type option controls whether it's a conjunction ("and"), disjunction ("or"), or unit list (no connector). The style option controls the length of the connectors.
Different languages have different plural rules. English has two categories: "one" (1) and "other" (0, 2+). Arabic has six categories: "zero", "one", "two", "few", "many", and "other". Chinese has only one category ("other" for all numbers). Intl.PluralRules helps you determine which plural form to use for a given number, which is essential for proper i18n in apps — e.g., showing "1 message" vs "2 messages" in English, or the correct form in more complex languages.
Use Intl.Collator when you need to compare many strings with the same collation rules (like sorting an array). It's more performant because the collation rules are compiled once. For one-off comparisons, String.prototype.localeCompare() is more convenient. Both support the same options including sensitivity (base/accent/case/variant), numeric ordering (so "file10" comes after "file2"), and caseFirst.
Use feature detection: if (typeof Intl.ListFormat === 'function') { /* supported */ }. You can also check locale support with Intl.NumberFormat.supportedLocalesOf(['en-US', 'xx-XX']) which returns only the valid locales. For time zones, use Intl.supportedValuesOf?.('timeZone') (Chrome 99+). Always feature-detect rather than browser-sniff for robust internationalization.
Yes! Node.js has built-in support for the Intl API. Starting from Node.js 13+, full ICU (International Components for Unicode) data is included by default, meaning all locales and features are available. For older versions (Node 0.12–12), you might need to use the --with-intl=full-icu flag or install the full-icu npm package. Check with new Intl.DateTimeFormat('fr-FR').resolvedOptions().timeZone to verify ICU data availability.