JavaScript Array toLocaleString() Method

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Locale string

What You’ll Learn

The toLocaleString() method turns an array into a comma-separated string, formatting each element for a locale (numbers, dates, currency). It does not change the array. This tutorial covers syntax, options, comparison with toString(), and five examples.

01

Syntax

toLocaleString(loc?, opt?)

02

Returns

String

03

Join

Commas

04

Locale

en-US, de-DE

05

Options

currency, etc.

06

vs toString

Localized

Introduction

When you display prices, dates, or large numbers to users worldwide, raw values like 1234567.89 are hard to read. toLocaleString() formats each array element according to a locale, then joins them with commas—similar to toString(), but locale-aware.

It is read-only: the array stays the same. You get back a string ready for UI labels, alerts, or logging.

Understanding the toLocaleString() Method

array.toLocaleString(locales?, options?) calls toLocaleString on each element (with the same locales and options), then joins the results with a comma (","). Empty slots in sparse arrays are omitted like join.

Under the hood it is like: arr.map(el => el.toLocaleString(locales, options)).join(",") (with spec details for null/undefined).

💡
Beginner Tip

toLocaleString() formats numbers and dates—it does not translate plain text. ["Hello","Hola"].toLocaleString("de-DE") still shows those words unchanged.

📝 Syntax

General form of Array.prototype.toLocaleString:

JavaScript
array.toLocaleString(locales, options)

Parameters

  • locales (optional) — BCP 47 tag such as "en-US" or "de-DE".
  • options (optional) — formatting object passed to each element (e.g. currency for numbers).

Return value

  • A string of locale-formatted elements joined by commas.

Common patterns

  • arr.toLocaleString() — default locale of the environment.
  • arr.toLocaleString("en-US") — US number/date style.
  • prices.toLocaleString("en-US", { style: "currency", currency: "USD" })
  • dates.toLocaleString("en-GB", { dateStyle: "medium" })
  • String(arr) or arr.toString() — non-localized alternative.

⚡ Quick Reference

GoalCode
Localized joinarr.toLocaleString()
Specific localearr.toLocaleString("de-DE")
Currency listarr.toLocaleString("en-US", { style: "currency", currency: "USD" })
Plain join (no locale)arr.toString()
Custom separatorarr.map(...).join(" | ")
Mutates array?No

📋 toLocaleString() vs toString() vs join()

All produce strings; only toLocaleString applies locale rules per element.

toLocaleString
locale format

i18n

toString
default str

Simple

join
any sep

Flexible

JSON.stringify
JSON text

Data

Examples Gallery

Open DevTools Console (F12) or use Try-it labs. Example N maps to ?tryit=N. Locale output may vary slightly by browser; examples use explicit locales where shown.

📚 Getting Started

Basic localized number formatting.

Example 1 — Format Numbers (US Locale)

Large numbers get grouping separators.

JavaScript
const numbers = [1234.5, 9876543.21];

const text = numbers.toLocaleString("en-US");

console.log(text);
// "1,234.5,9,876,543.21"
Try It Yourself

How It Works

Each number calls Number.prototype.toLocaleString("en-US"), then results join with commas.

Example 2 — German Locale (de-DE)

Decimal comma and dot as thousands separator in Germany.

JavaScript
const numbers = [1234.5, 9876];

const text = numbers.toLocaleString("de-DE");

console.log(text);
// "1.234,5,9.876"
Try It Yourself

How It Works

Same values, different locale rules. Always pass an explicit locale when you need predictable output across users.

📈 Practical Patterns

Currency, dates, and comparison with toString.

Example 3 — Currency Formatting

Pass style and currency in options.

JavaScript
const prices = [1000, 2500, 99.5];

const text = prices.toLocaleString("en-US", {
  style: "currency",
  currency: "USD"
});

console.log(text);
// "$1,000.00,$2,500.00,$99.50"
Try It Yourself

How It Works

Options apply to each numeric element. Great for price lists in dashboards or receipts.

Example 4 — Format Dates in an Array

Date objects use locale date/time formatting.

JavaScript
const dates = [
  new Date("2024-06-15T12:00:00Z"),
  new Date("2024-12-25T12:00:00Z")
];

const text = dates.toLocaleString("en-US", { dateStyle: "medium" });

console.log(text);
// e.g. "Jun 15, 2024,Dec 25, 2024"
Try It Yourself

How It Works

Each Date calls its own toLocaleString. For a single custom separator, map and join instead.

Example 5 — toLocaleString() vs toString()

Same array, different formatting for numbers.

JavaScript
const values = [1234567.89];

console.log(values.toString());
// "1234567.89"

console.log(values.toLocaleString("en-US"));
// "1,234,567.89"
Try It Yourself

How It Works

toString() is plain conversion. toLocaleString() adds locale grouping and formatting rules.

🚀 Common Use Cases

  • Price lists — format multiple amounts as currency.
  • Reports — locale-aware number columns in one string.
  • Date ranges — show selected dates for a locale.
  • Debug snapshots — quick readable array string in logs.
  • Legacy UI — display array contents without manual map.
  • Implicit coercionalert(arr) uses toString, not locale (use explicitly when needed).

🧠 How toLocaleString() Runs

1

Loop elements

Skip empty holes in sparse arrays.

Iterate
2

Format each

Call element.toLocaleString(locales, options).

Locale
3

Join with comma

Same separator as toString/join default.

Join
4

Return string

Array unchanged.

📝 Notes

  • Does not mutate the array.
  • Returns a string, not an array.
  • Separator is always comma (no parameter to change it—use map + join).
  • Does not translate plain strings.
  • null and undefined become empty string segments per spec.
  • Objects without toLocaleString fall back to toString.
  • For production i18n UI, prefer Intl.NumberFormat / Intl.DateTimeFormat per field.

Browser & Runtime Support

Array.prototype.toLocaleString() has been available since ES3. Modern locales and options rely on the engine's Intl API (excellent in current browsers).

Baseline · ES3

Array.prototype.toLocaleString()

Supported everywhere for basic use. Locale-specific formatting quality is best in Chrome, Firefox, Safari, Edge, and Node.js with full ICU data.

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
Array.toLocaleString() Excellent

Bottom line: Safe in all environments. Pass explicit locales in apps that must look identical for every user.

Conclusion

toLocaleString() turns arrays into readable, locale-aware comma-separated strings. Use it for numbers, dates, and currency; use toString() when you need simple default conversion.

Next, learn toString() for the non-localized string form of arrays.

💡 Best Practices

✅ Do

  • Pass explicit locales in user-facing apps
  • Use currency options for money arrays
  • Compare with toString when debugging format
  • Use map + join for custom separators
  • Prefer Intl formatters for complex UI

❌ Don’t

  • Expect plain strings to be translated
  • Rely on default locale for critical financial display
  • Parse the result back into an array (use JSON instead)
  • Assume comma separator works in all UX contexts
  • Confuse display strings with data storage format

Key Takeaways

Knowledge Unlocked

Five things to remember about Array.toLocaleString()

Locale-aware comma-separated display strings.

5
Core concepts
🌐 02

Locale

en-US, de-DE.

i18n
💰 03

Currency

style + currency.

Money
📅 04

Dates

dateStyle.

Time
05

vs toString

Localized.

Compare

❓ Frequently Asked Questions

toLocaleString() converts each array element to a string using locale-aware formatting (when the element supports it), then joins them with commas. It returns one string and does not mutate the array.
No. toLocaleString() only reads elements and returns a new string. The original array is unchanged.
Both join elements with commas. toLocaleString() passes locale and options to each element's toLocaleString method, so numbers, dates, and other locale-sensitive values format for the user's region. toString() uses default string conversion without localization.
locales is a BCP 47 language tag (e.g. 'en-US', 'de-DE') or array of tags. options is an object forwarded to each element's toLocaleString—for example { style: 'currency', currency: 'USD' } for numbers.
No. Plain strings like 'Hello' are not translated. Localization applies to how numbers, dates, and similar values are formatted—not automatic translation of words.
Array.toLocaleString() has been available since ES3 and works in all browsers. Locale and option support depends on the engine's Intl implementation (excellent in modern browsers).
Did you know?

When you concatenate an array with a string ("Prices: " + arr), JavaScript calls toString(), not toLocaleString(). Call toLocaleString() explicitly when you want locale formatting.

Continue to toString()

Learn the default string conversion for arrays without locale formatting.

toString() tutorial →

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.

6 people found this page helpful