Jsref Tolocalestring Number
[ JavaScript Number Object](#)
## Examples
Use locale settings to format a string:
let num1 = 1000000; let text1 = num1.toLocaleString(); let num2 = 1000000; let text2 = num2.toLocaleString("fi-FI"); let num3 = 1000000; let text3 = num3.toLocaleString("zh-CN", {style:"currency", currency:"CNY"}); let num4 = 1000000; let text4 = num4.toLocaleString("en-US", {style:"currency", currency:"USD"});
[Try it Β»](#)
* * *
## Definition and Usage
The toLocaleString() method returns a string representing the number in a specific locale.
The new locales and options parameters let applications specify which language formatting conventions to use, and customize the behavior of the function. In older implementations, the locales and options parameters are ignored, and the locale used and the form of the string returned are entirely dependent on the implementation.
* * *
## Browser Support
Number.toLocaleString() is an ECMAScript 3 (ES3) feature.
All browsers support ES3 (JavaScript 1999).
| | | | | | |
| --- | --- | --- | --- | --- | --- |
| Chrome | IE | Edge | Firefox | Safari | Opera |
| Yes | Yes | Yes | Yes | Yes | Yes |
All modern browsers support (locales, options) parameters:
| | | | | | |
| --- | --- | --- | --- | --- | --- |
| Chrome | IE | Edge | Firefox | Safari | Opera |
| Yes | 11 | Yes | Yes | Yes | Yes |
* * *
## Syntax
number.toLocaleString(locales, options)
## Parameter Values
| Parameter | Description |
| --- | --- |
| _locales_ | Optional, formatting object, can be: `ar-SA` Arabic (Saudi Arabia) `bn-BD` Bengali (Bangladesh) `bn-IN` Bengali (India) `cs-CZ` Czech (Czech Republic) `da-DK` Danish (Denmark) `de-AT` Austrian German `de-CH` "Swiss" German `de-DE` Standard German `el-GR` Modern Greek `en-AU` Australian English `en-CA` Canadian English `en-GB` British English `en-IE` Irish English `en-IN` Indian English `en-NZ` New Zealand English `en-US` American English `en-ZA` English (South Africa) `es-AR` Argentine Spanish `es-CL` Chilean Spanish `es-CO` Colombian Spanish `es-ES` Castilian Spanish (used in north-central Spain) `es-MX` Mexican Spanish `es-US` US Spanish `fi-FI` Finnish (Finland) `fr-BE` Belgian French `fr-CA` Canadian French `fr-CH` "Swiss" French `fr-FR` Standard French (in France) `he-IL` Hebrew (Israel) `hi-IN` Hindi (India) `hu-HU` Hungarian (Hungary) `id-ID` Indonesian (Indonesia) `it-CH` "Swiss" Italian `it-IT` Standard Italian (in Italy) `ja-JP` Japanese (Japan) `ko-KR` Korean (South Korea) `nl-BE` Belgian Dutch `nl-NL` Standard Dutch `no-NO` Norwegian (Norway) `pl-PL` Polish (Poland) `pt-BR` Brazilian Portuguese `pt-PT` European Portuguese `ro-RO` Romanian (Romania) `ru-RU` Russian (Russian Federation) `sk-SK` Slovak (Slovakia) `sv-SE` Swedish (Sweden) `ta-IN` Tamil (India) `ta-LK` Tamil (Sri Lanka) `th-TH` Thai (Thailand) `tr-TR` Turkish (Turkey) `zh-CN` Mainland China, Simplified Chinese `zh-HK` Hong Kong, Traditional Chinese `zh-TW` Taiwan, Traditional Chinese |
| _options_ | Optional, can be: * `"decimal"` for plain number format; * `"currency"` for currency format; * `"percent"` for percentage format; * `"unit"` for unit format |
## Return Value
| Type | Description |
| --- | --- |
| String | Returns a string representing the number in a locale. |
## Technical Details
| JavaScript Version: | ECMAScript 6 |
| --- |
* * *
## More Examples
## Examples
Use optional parameters to format currency strings:
let num1 = new Number(1000000); const myObj = {style: "currency", currency: "EUR"}let text1 = num1.toLocaleString("en-GB", myObj); let num2 = new Number(1000000); let text2 = num2.toLocaleString("en-GB", {style:"currency", currency:"EUR"}); let num3 = 1000000; let text3 = num3.toLocaleString("zh-CN", {style:"currency", currency:"CNY"}); let num4 = 1000000; let text4 = num4.toLocaleString("ja-JP", {style:"currency", currency:"JPY"});
[Try it Β»](#)
[ JavaScript Number Object](#)
YouTip