Intl.NumberFormat
Creates an Intl.NumberFormat object that enables language-sensitive number formatting
Syntax
new Intl.NumberFormat(locales?, options?)Parameters
| Parameter | Type | Description |
|---|---|---|
| locales | string | string[] | A BCP 47 language tag or array of such tags |
| options | Intl.NumberFormatOptions | Options for number formatting (style, currency, notation, etc.) |
Return Value
An Intl.NumberFormat object with a format() method
Examples
const fmt = new Intl.NumberFormat('en-US')
console.log(fmt.format(1234567.89)) // '1,234,567.89'const currency = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
})
console.log(currency.format(42.5)) // '$42.50'const compact = new Intl.NumberFormat('en', {
notation: 'compact',
compactDisplay: 'short'
})
console.log(compact.format(1500000)) // '1.5M'Understanding Intl.NumberFormat
The Intl.NumberFormat method in JavaScript creates an Intl.NumberFormat object that enables language-sensitive number formatting. It belongs to the Intl object and is one of the most widely used methods for working with intl values in modern JavaScript and TypeScript applications.
The method signature is new Intl.NumberFormat(locales?, options?). It accepts 2 parameters: locales, options. When called, it returns an intl.numberformat object with a format() method. Understanding when and how to use NumberFormat() helps you write more expressive, readable code.
Common use cases for Intl.NumberFormat include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like intl-numberformat-format, intl-numberformat-formattoparts, intl-datetimeformat, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Intl.NumberFormat is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
Intl.NumberFormat.prototype.formatFormats a number according to the locale and formatting options of this Intl.NumberFormat object
Intl.NumberFormat.prototype.formatToPartsFormats a number and returns an array of objects representing the formatted number in parts
Intl.DateTimeFormatCreates an Intl.DateTimeFormat object that enables language-sensitive date and time formatting
More Intl Methods
Other methods in the Intl object
Related Tools
More Intl Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.