Number.prototype.toLocaleString()
number.toLocaleString(locales, options)
Returns the number as a string in the form usual for the given language – in American English with commas between thousands and a decimal point, in German the other way round. The options handle a currency, percentages and the number of decimal places.
Parameters
- locales – optional, for example
'en-US'. - options – optional, for example
style: 'currency', currency: 'USD',style: 'percent',minimumFractionDigits,maximumFractionDigits.
Return value
A string.
Examples
console.log((1234567.891).toLocaleString('en-US'));
console.log((1234.5).toLocaleString('en-US', { style: 'currency', currency: 'USD' }));
console.log((0.215).toLocaleString('en-US', { style: 'percent', maximumFractionDigits: 1 }));
console.log((1234.5).toLocaleString('de-DE', { minimumFractionDigits: 2 }));
Output:
1,234,567.891 $1,234.50 21.5% 1.234,50
Things to watch out for
- Some languages (French, Czech) use a non-breaking space as the thousands separator, not an ordinary one – keep that in mind when comparing strings or in tests.
- Always state the language, otherwise the result depends on the browser settings.
- When formatting many numbers, one
new Intl.NumberFormat('en-US', options)and itsformat()is faster.
Browser support
Baseline – widely available: works in all major browsers and has for a long time (since 2015 at the latest). Since version: Chrome 1, Firefox 1, Safari 1; Node.js 0.10.0. As of October 2026 (MDN browser-compat-data).
Related:
Number.prototype.toFixed()
Intl.NumberFormat
Number.prototype.toString()