JavaScript Number toLocaleString() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

number.toLocaleString(locales, options) returns a string of the number formatted for a language or region. It can add grouping separators, change the decimal mark, and show currency symbols.

Use it when you show prices or counts to people. Keep the raw number for math, and format only for display.

Syntax

Call toLocaleString on a number. Start with this line.

JavaScript
n.toLocaleString()
n.toLocaleString(locales)
n.toLocaleString(locales, options)
CallWhat it does
n.toLocaleString()Format with the runtime default locale.
n.toLocaleString(locales)Format for one language tag (or a list of tags).
n.toLocaleString(locales, options)Add style, currency, and digit options.

Built into JavaScript. Call toLocaleString(...) on a number (or Number instance) — no import required. Under the hood it uses Intl.NumberFormat.

Library declarations
JavaScript
Number.prototype.toLocaleString([locales[, options]])

Parameters

ParameterDescription
localesOptional. A BCP 47 tag such as "en-US", "de-DE", or "en-IN", or an array of tags.
optionsOptional. Object with keys like style, currency, minimumFractionDigits, and maximumFractionDigits.

Return Value

Return ValueDescription
stringA locale-aware display string for the number.

JavaScript Examples

Example 1 — Default Locale and Explicit Locales

Omit arguments for the default locale, or pass a language tag for a fixed format.

JavaScript
const n = 123456.789;

console.log(n.toLocaleString("en-US"));  // "123,456.789"
console.log(n.toLocaleString("de-DE"));  // "123.456,789"
console.log(n.toLocaleString("en-IN"));  // "1,23,456.789"
console.log(typeof n.toLocaleString("en-US")); // "string"
Try It Yourself

How It Works

  1. US English. Uses a comma for thousands and a dot for decimals.
  2. German. Swaps the separators: dot for thousands, comma for decimals.
  3. Indian English. Uses the Indian grouping pattern (1,23,456).
  4. String result. typeof is always "string".

Example 2 — Currency Formatting

Set style: "currency" and a three-letter currency code.

JavaScript
const price = 1999.5;

console.log(price.toLocaleString("en-US", {
  style: "currency",
  currency: "USD"
}));
// "$1,999.50"

console.log(price.toLocaleString("en-IN", {
  style: "currency",
  currency: "INR"
}));
// "₹1,999.50" (symbol may vary by engine)
Try It Yourself

How It Works

  1. Style currency. Tells the formatter to treat the value as money.
  2. Currency code. "USD" and "INR" pick the symbol and fraction rules.
  3. Locale still matters. Grouping and symbol placement follow the locale.
  4. Display only. Store 1999.5 as a number; format when you show it.

Example 3 — Control Decimal Digits

Use fraction digit options when you want a fixed count of places with locale separators.

JavaScript
const n = 12.5;

console.log(n.toLocaleString("en-US", {
  minimumFractionDigits: 2,
  maximumFractionDigits: 2
}));
// "12.50"

console.log(n.toLocaleString("de-DE", {
  minimumFractionDigits: 2,
  maximumFractionDigits: 2
}));
// "12,50"

console.log((0.256).toLocaleString("en-US", {
  style: "percent",
  maximumFractionDigits: 1
}));
// "25.6%"
Try It Yourself

How It Works

  1. Pad decimals. Min/max fraction digits keep two places: "12.50".
  2. Locale decimal mark. German uses a comma: "12,50".
  3. Percent style. Multiplies by 100 and adds %.
  4. vs toFixed. toFixed(2) is always plain "12.50" with a dot — no locale rules.

Browser & Runtime Support

Number.prototype.toLocaleString() is part of core JavaScript. Full Intl options are Baseline Widely available in modern engines.

✓ Baseline · Intl

Number.toLocaleString()

Safe in every modern browser and Node.js. Pass an explicit locale when output must match across machines.

99% Universal support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
toLocaleString Excellent

Bottom line: Ideal for UI prices and counts. Keep raw numbers for math; format only when displaying.

Frequently Asked Questions

Number.prototype.toLocaleString() returns a string of the number formatted for a language or region. It can add thousand separators, change decimal marks, and format currency. Example: (123456.789).toLocaleString("en-US") is often "123,456.789".
locales is an optional BCP 47 language tag such as "en-US" or "de-DE" (or an array of tags). options is an optional object for style ("decimal", "currency", "percent"), currency codes, and digit counts. Omit both to use the runtime default locale.
Always a string. Use it for display. Convert again with Number() or parseFloat() only if you need more math — and be careful: locale strings may contain commas or currency symbols.
toFixed() always uses a plain decimal form with a fixed count of places. toString() prints a plain number string (optionally in another base). toLocaleString() follows locale rules for separators, symbols, and currency.
When you omit locales, the browser or Node.js uses its default locale. Pass an explicit locale such as "en-IN" when you need the same format everywhere.
Basic toLocaleString() is old and widely available. Full Intl options (currency, digit controls) are Baseline Widely available in modern browsers and Node.js.

Next: toPrecision()

Learn how toPrecision() formats by total significant digits.

toPrecision() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful