正在加载,请稍候…

Number Formatting: Thousands Separators, Decimals, and Locale Formats

Format numbers with thousands separators, decimal points, and currency symbols for different locales.

Why Number Formatting Matters

The same number can be written in dozens of ways depending on locale, context, and convention. Formatting numbers correctly is essential for financial applications, data dashboards, internationalized software, and anywhere numbers are displayed to human users.

Locale-Specific Number Formats

Numbers are formatted differently around the world:

Locale Example Number Formatted
en-US (English, USA) 1234567.89 1,234,567.89
de-DE (German, Germany) 1234567.89 1.234.567,89
fr-FR (French, France) 1234567.89 1 234 567,89
en-IN (English, India) 1234567.89 12,34,567.89
ja-JP (Japanese, Japan) 1234567.89 1,234,567.89
ar-SA (Arabic, Saudi Arabia) 1234567.89 ١٬٢٣٤٬٥٦٧٫٨٩

Key differences:

  • Decimal separator: Period (.) in English-speaking countries, comma (,) in Europe
  • Thousands separator: Comma, period, space, or apostrophe depending on locale
  • Grouping: Most use groups of 3, India uses the lakh system (2,2,3 grouping)
  • Digit characters: Arabic, Persian, and other scripts have their own digit symbols

The Intl.NumberFormat API

Modern JavaScript provides Intl.NumberFormat for locale-aware number formatting:

// Currency formatting
new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD'
}).format(1234567.89);
// → "$1,234,567.89"

new Intl.NumberFormat('de-DE', {
  style: 'currency',
  currency: 'EUR'
}).format(1234567.89);
// → "1.234.567,89 €"

// Compact notation
new Intl.NumberFormat('en-US', {
  notation: 'compact',
  compactDisplay: 'short'
}).format(1234567);
// → "1.2M"

// Percentage
new Intl.NumberFormat('en-US', {
  style: 'percent',
  minimumFractionDigits: 1
}).format(0.1234);
// → "12.3%"

Number Display Formats

Standard Decimal

The default representation with decimal separator and optional grouping.

Scientific Notation

Useful for very large or very small numbers:

  • 1.23456 × 10⁹ (typographic)
  • 1.23456e9 (programming notation)

Compact/Abbreviation

Makes large numbers readable at a glance:

  • 1,200 → "1.2K"
  • 1,500,000 → "1.5M"
  • 1,000,000,000 → "1B"

Compact notation is widely used in dashboards, social media follower counts, and financial summaries.

Percentage

Convert decimal fractions to percentage format: 0.1234 → 12.34%

Currency

Add currency symbol, code, or both:

  • Symbol: $1,234.56
  • Code: USD 1,234.56
  • Name: 1,234.56 US dollars

Ordinal

Number position: 1st, 2nd, 3rd, 4th... (varies by language)

Precision and Rounding

Significant Digits

The number of meaningful digits in a value:

  • 1,234.5678 rounded to 4 significant digits = 1,235
  • 0.001234 rounded to 4 significant digits = 0.001234

Decimal Places

Fixed number of digits after the decimal:

  • 1234.5 with 2 decimal places = 1234.50
  • 1234.5678 with 2 decimal places = 1234.57 (rounded)

Rounding Modes

  • Round half up: 2.5 → 3 (common in everyday use)
  • Round half to even (banker's rounding): 2.5 → 2, 3.5 → 4 (minimizes systematic bias)
  • Truncate: 2.9 → 2 (drops the fractional part)

Financial Number Formatting

Finance requires particular care:

  • Always show exactly 2 decimal places for currencies with cents
  • Some currencies have no cents (JPY, KRW) — never show decimal places
  • Some currencies use 3 decimal places (KWD, BHD)
  • Display negative values with parentheses in accounting: (1,234.56) instead of -1,234.56
  • Show exact values, not compact notation, in financial statements

Using the Number Formatter Tool

Our tool:

  1. Enter any number — integers, decimals, large or small
  2. Choose locale — see formatting for any regional standard
  3. Select format type — decimal, currency, percentage, compact, scientific
  4. Configure precision — decimal places or significant digits
  5. Choose currency — for currency formatting, select from all ISO 4217 codes
  6. Copy formatted result — ready to paste anywhere

Use it for localization work, financial applications, dashboard design, and understanding how numbers appear to users in different countries.