Grouping and Notation Options
You'll learn how to control whether thousands separators appear in formatted numbers and how to switch between standard, scientific, and compact notations in Intl.NumberFormat.
What Are Grouping and Notation?
When formatting numbers, you often want control over two visual aspects:
- Grouping: Should large numbers display separators? (
1000000vs1,000,000) - Notation: How should the number be represented? (
1000000vs1Mvs1E6)
The Intl.NumberFormat API lets you configure both through options when creating your formatter.
Disabling Digit Grouping
By default, most locales group digits with commas or spaces. You can disable this with useGrouping: false:
const withGrouping = new Intl.NumberFormat('en-US');
console.log(withGrouping.format(5000000)); // "5,000,000"
const withoutGrouping = new Intl.NumberFormat('en-US', { useGrouping: false });
console.log(withoutGrouping.format(5000000)); // "5000000"
Choosing a Notation
The notation option controls how numbers are displayed:
const standard = new Intl.NumberFormat('en-US', { notation: 'standard' });
console.log(standard.format(1500000)); // "1,500,000"
const scientific = new Intl.NumberFormat('en-US', { notation: 'scientific' });
console.log(scientific.format(1500000)); // "1.5E6"
const compact = new Intl.NumberFormat('en-US', { notation: 'compact' });
console.log(compact.format(1500000)); // "1.5M"
Compact notation is perfect for dashboards and social media (showing "2.4K likes" instead of "2,400 likes"). Scientific notation is useful for extremely large or small numbers in technical contexts.
Key Takeaway: Use useGrouping: false to remove thousands separators, and set notation to 'standard', 'scientific', or 'compact' to control how your numbers are represented for readability in different contexts.