var number = 123456.789; // request a currency format console.log(number.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' })); // → 123.456,79 € // the Japanese yen doesn't use a minor unit console.log(number.toLocaleString('ja-JP', { style: 'currency', currency: 'JPY' })) // → ¥123,457 // limit to three significant digits console.log(number.toLocaleString('en-IN', { maximumSignificantDigits: 3 })); // → 1,23,000 // Use the host default language with options for number formatting var num = 30000.65; console.log(num.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})); // → "30,000.65" where English is the default language, or // → "30.000,65" where German is the default language, or // → "30 000,65" where French is the default language
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter