Intl.NumberFormat.prototype.format
Formats a number according to the locale and formatting options of this Intl.NumberFormat object
Syntax
numberFormat.format(number)Parameters
| Parameter | Type | Description |
|---|---|---|
| number | number | bigint | The number to format |
Return Value
A string containing the formatted number
Examples
const fmt = new Intl.NumberFormat('de-DE')
console.log(fmt.format(1234567.89)) // '1.234.567,89'const percent = new Intl.NumberFormat('en-US', { style: 'percent' })
console.log(percent.format(0.75)) // '75%'const bytes = new Intl.NumberFormat('en', {
style: 'unit',
unit: 'megabyte',
unitDisplay: 'narrow'
})
console.log(bytes.format(512)) // '512MB'Understanding Intl.NumberFormat.prototype.format
The Intl.NumberFormat.prototype.format method in JavaScript formats a number according to the locale and formatting options of this Intl.NumberFormat object. It belongs to the Intl.NumberFormat object and is one of the most widely used methods for working with intl.numberformat values in modern JavaScript and TypeScript applications.
The method signature is numberFormat.format(number). It accepts 1 parameter: number. When called, it returns a string containing the formatted number. Understanding when and how to use format() helps you write more expressive, readable code.
Common use cases for Intl.NumberFormat.prototype.format include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like intl-numberformat, intl-numberformat-formattoparts, intl-numberformat-formatrange, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Intl.NumberFormat.prototype.format 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.NumberFormatCreates an Intl.NumberFormat object that enables language-sensitive number formatting
Intl.NumberFormat.prototype.formatToPartsFormats a number and returns an array of objects representing the formatted number in parts
Intl.NumberFormat.prototype.formatRangeFormats a range of numbers according to the locale and formatting options of this Intl.NumberFormat object
More Intl.NumberFormat Methods
Other methods in the Intl.NumberFormat object
Related Tools
More Intl.NumberFormat Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.