Number formatter

What is a Number Formatter?

Raw numbers like 1234567.891 are hard to read. Formatting adds grouping separators, rounds to a sensible number of decimals and adapts to local conventions. This formatter shows how a number looks with different options and locales, using the same rules as JavaScript's Intl.NumberFormat.

How to use it

  1. Enter a number.
  2. Choose the locale, the number of decimal places and the notation.
  3. Copy the formatted result.

Examples for 1234567.891

  • en-US: 1,234,567.891
  • de-DE: 1.234.567,891
  • fr-FR: 1 234 567,891 (with a narrow non-breaking space)
  • en-IN: 12,34,567.891
  • Compact: 1.2M
  • Scientific: 1.235E6
  • Two decimals: 1,234,567.89

In code

new Intl.NumberFormat('en-US', { notation: 'compact' }).format(1234567) // '1.2M'
new Intl.NumberFormat('en-US', { style: 'percent' }).format(0.256)   // '26%'

Things to watch

  • Formatted numbers are text. Never store or calculate with them; parse the original value instead. 1.234 means one thousand two hundred and thirty-four in German but one point two three four in English.
  • Rounding: formatting rounds for display only; keep full precision in calculations.
  • Percent style multiplies by 100, so pass 0.256 for 25.6%.
  • Compact notation is great for dashboards but loses precision; show the exact value in a tooltip.

Frequently Asked Questions

Why does Germany use a dot as the thousands separator?

Many European locales use a comma as the decimal separator and a dot or space for grouping, the reverse of English conventions.

How do I show 1.2K or 3.4M?

Use compact notation, which abbreviates thousands, millions and billions.

Should I store formatted numbers?

No. Store the raw numeric value and format it only for display.

Why is my percentage 100 times too large?

Percent formatting multiplies by 100. Pass 0.25 to display 25 percent.

How do I always show two decimal places?

Set both the minimum and maximum fraction digits to 2. The value 5 is then shown as 5.00 and 3.14159 as 3.14.

What is the Indian numbering format?

In the en-IN locale the first group has three digits and the following groups have two, so ten million is written 1,00,00,000, which is one crore.