JavaScript Number.prototype.toLocaleString() Method
The toLocaleString() method formats a number for a given language and region, with the right digit grouping, decimal separator and optional currency.
Description
The toLocaleString() method returns a language-sensitive representation of the number, using Intl.NumberFormat behind the scenes. Without arguments it uses the user's language, so the same number may show as "1,234.5" or "1.234,5". Options let you format currency, percentages and units, and control decimal places.
Each call creates a new formatter behind the scenes, so when formatting many numbers with the same settings, create one Intl.NumberFormat and reuse its format() method, which is noticeably faster. The output is meant for people, so don't parse it back into a number or store it.
Options include minimumFractionDigits and maximumFractionDigits to control decimals, notation: 'compact' for short forms such as "1.2K", and style: 'unit' with a unit like 'kilobyte' for measurements. BigInts and dates have their own toLocaleString() methods.
Syntax
number.toLocaleString()
number.toLocaleString(locales, options)Parameters
- localesOptional. A language tag such as
"en-AU". - optionsOptional. The same options as
Intl.NumberFormat, such asstyleandcurrency.
Return Value
A string with the number formatted for the language.
Example
Browser Support
The following information will show you the current browser support for the Number.prototype.toLocaleString() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





