How to format numbers for any locale
- Enter a number, using a dot for decimals.
- Choose the locale, for example
en-US,de-DEoren-IN, and a style: plain decimal, currency, percent, compact (1.2M), scientific, units such as km/h, or file sizes. - Set the minimum and maximum decimal places and digit grouping.
- Copy the result, or copy the JavaScript
Intl.NumberFormatcode that produces it. The table shows the same number in 20 locales.
Why number formatting is tricky
Conventions differ around the world. The US writes 1,234,567.89, Germany 1.234.567,89, France 1 234 567,89 with narrow spaces, Switzerland 1’234’567.89 and India groups in lakhs and crores as 12,34,567.89. Currency symbols go before or after the number, with or without a space, and some currencies such as the Japanese yen have no decimal places. Getting this wrong confuses customers and can even make prices look ten or a thousand times off.
The browser's built-in Intl.NumberFormat API handles all of this using the Unicode CLDR data, so the code you copy here works in every modern browser and in Node.js without a library. Always format numbers for display only; store and calculate with raw numbers. Percent style multiplies by 100, so pass 0.25 to show 25%.
Everything is calculated in your browser.
How do I add thousands separators in JavaScript?
Use n.toLocaleString() or new Intl.NumberFormat("en-US").format(n). Both add the separators for the given locale.
Why does my currency show a code instead of a symbol?
Some locale and currency combinations use the ISO code to avoid ambiguity, such as US$ or CA$. Pass currencyDisplay: "narrowSymbol" to prefer a bare symbol like $.
Why are file sizes shown in KB of 1,000 bytes?
That is the SI convention used by macOS, phones and storage makers. Windows uses 1,024-byte units, properly called KiB and MiB.