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
Fundamentals
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.
Concept
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.
Foundation
📝 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.
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
Hands-On
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.
toString() is plain conversion. toLocaleString() adds locale grouping and formatting rules.
Applications
🚀 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 coercion — alert(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.
Important
📝 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.
Compatibility
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 ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · 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.
Wrap Up
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.
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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Array.toLocaleString()
Locale-aware comma-separated display strings.
5
Core concepts
📝01
Syntax
toLocaleString(loc, opt)
API
🌐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.