How to use the number formatter
- Enter the Number, for example
1234567.891. Spaces, underscores and apostrophes are stripped as grouping marks. A comma is grouping (1,234,567.89) unless it is the last separator and not plain three-digit grouping (1 234 567,89,1.234.567,89); then it is read as the decimal mark and a note says so. - Choose the Locale, for example English (India) (en-IN) or German (de-DE).
- Pick a Style: Number, Currency, Percent (×100), Compact (1.2M), Scientific or Engineering. For Currency, choose one of 12 Currency codes.
- Set Decimal places (0–20) and tick or untick Thousands separators.
- Read Formatted, compare it with the other 16 locales in the table, and copy the JavaScript line if you want the same result in code.
What it does and when to use it
Hard-coding commas and dots breaks as soon as an app is used in another country. This tool shows what Intl.NumberFormat will produce before you ship. Use it to check an invoice layout, a dashboard in several markets, or a test that compares formatted strings.
For file sizes use the bytes humanizer. To turn written numbers such as “two thousand” into digits, use words to number. For durations, use the duration humanizer.
How it works
The cleaned input is converted with Number(). Anything that is not a finite number gives an error like "abc" is not a number. The tool then builds an options object and calls new Intl.NumberFormat(locale, options).format(n) in your browser:
- Number, Currency and Percent use
minimumFractionDigitsandmaximumFractionDigitsequal to your decimal places, plususeGrouping. - Compact uses
notation: "compact"with at most 2 decimals. It ignores the separators checkbox. - Scientific and Engineering set
notationand a maximum number of decimals.
The JavaScript line repeats those exact options.
Worked examples
1234567.891 with 2 decimal places, Number style:
English (US) (en-US) | 1,234,567.89
English (India) (en-IN) | 12,34,567.89
German (de-DE) | 1.234.567,89
German (Switzerland) (de-CH) | 1'234'567.89
The JavaScript line for en-IN:
new Intl.NumberFormat("en-IN", {"useGrouping":true,"minimumFractionDigits":2,"maximumFractionDigits":2}).format(1234567.891)
Compact style turns the same number into 1.23M in en-US, 12.35L in en-IN and 1,23 Mio. in de-DE.
European input: 1 234 567,89 gives Formatted: 1,234,567.89 in en-US, with the note The comma in "1 234 567,89" was read as the decimal mark, so the number is 1234567.89.
Limits and tips
- Precision. Values above 9,007,199,254,740,991 in size are rejected, and long decimals are limited by double-precision floating point. Do money arithmetic in integer minor units, and format only at the end.
- Hidden spaces. French, Swedish and Russian group with no-break spaces, which can make string comparisons in tests fail.
Frequently asked questions
Can I type 1 234 567,89 with a decimal comma?
How does Indian grouping differ?
Why does yen show two decimal places?
Will my users see exactly this output?
Does Percent multiply by 100?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.