Learn currency formatting, date formatting, number formatting, list formatting, and more with the JavaScript Intl API. Practical TypeScript examples and best practices.
JavaScript Intl API: Currency, Date, and Number Formatting (TypeScript)
The JavaScript Intl API is the built-in way to handle currency formatting, date formatting, **number formatting **, and a lot more. This guide walks through the most useful Intl features with expressive TypeScript examples you can drop into any app.
Note: results below show typical output for en-US in modern browsers/Node. Minor punctuation or casing can vary by
runtime and ICU data.
Interactive demo
Change locale, currency, amount, and date -- the same values format differently per audience:
Quick start: currency and date formatting
Result:
Intl.NumberFormat: numbers, currency, units, percent
Number formatting with locale and grouping
Result:
Currency formatting with precise rounding
Result:
Unit and percent formatting
Result:
Format to parts for custom UI
formatToParts is ideal if you need to style currency symbols or decimals separately.
Result:
Intl.DateTimeFormat: dates, times, time zones
Date and time styles
Result:
Time zone aware formatting
Result:
Range formatting
Result:
Format to parts for dates
Result:
Intl.ListFormat: list formatting
Result:
Intl.RelativeTimeFormat: relative time
Result:
Intl.PluralRules: pluralization
Result:
Intl.Collator: locale-aware sorting
Result:
Intl.DisplayNames: user-friendly labels
Result:
Intl.Segmenter: split text by words or graphemes
Result:
Intl.Locale and supported values
Result:
Practical tips for production usage
- Cache formatters: create them once and reuse, formatters are expensive to construct.
- *Prefer Intl.Format over toLocaleString: formatters are clearer and easier to test.
- Store numbers and dates as data: format at the UI boundary to avoid mixed locales.
- Pick explicit locales when formatting server-side (avoid environment surprises).
Result:
FAQ: Intl API for currency and date formatting
How do I format currency in JavaScript?
Use Intl.NumberFormat with style: "currency" and a currency code.
Result:
How do I format dates with Intl in JavaScript?
Use Intl.DateTimeFormat with dateStyle, timeStyle, and an optional timeZone.
Result: