The style Option: decimal, currency, percent, unit
You'll learn how to control number presentation by selecting the appropriate style option in Intl.NumberFormat.
The Four Core Styles
When you create an Intl.NumberFormat instance, the style option determines how the number should be interpreted and displayed. Think of it like choosing a costume for your number—same value, different presentation.
The four available styles are:
decimal (default)
Plain number formatting with locale-appropriate digit grouping and decimal separators. This is what you get if you don't specify a style.
new Intl.NumberFormat('en-US', { style: 'decimal' }).format(1234.56);
// "1,234.56"
currency
Formats as money with currency symbols. Requires the currency option (like 'USD' or 'EUR').
new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(1234.56);
// "$1,234.56"
percent
Multiplies by 100 and adds a percent sign. 0.42 becomes 42%.
new Intl.NumberFormat('en-US', { style: 'percent' }).format(0.42);
// "42%"
unit
Formats with measurement units like "kilometer" or "gigabyte". Requires the unit option.
new Intl.NumberFormat('en-US', { style: 'unit', unit: 'kilometer' }).format(1234.56);
// "1,234.56 km"
Why This Matters
Each style applies its own logic: currency adds symbols, percent scales values, units add labels. Choosing the right style ensures your numbers communicate meaning, not just digits.
Key Takeaway: The style option transforms raw numbers into contextually meaningful formats—decimal for plain numbers, currency for money, percent for ratios, and unit for measurements.