Object.prototype.toLocaleString() - JavaScript | MDN Skip to main content Skip to search MDN HTML HTML: Markup language HTML reference Elements Global attributes Attributes See all… HTML guides Responsive images HTML cheatsheet Date & time formats See all… Markup languages SVG MathML XML CSS CSS: Styling language CSS reference Properties Selectors At-rules Values See all… CSS guides Box model Animations Flexbox Colors See all… Layout cookbook Column layouts Centering an element Card component See all… JavaScriptJS JavaScript: Scripting language JS reference Standard built-in objects Expressions & operators Statements & declarations Functions See all… JS guides Control flow & error handing Loops and iteration Working with objects Using classes See all… Web APIs Web APIs: Programming interfaces Web API reference File system API Fetch API Geolocation API HTML DOM API Push API Service worker API See all… Web API guides Using the Web animation API Using the Fetch API Working with the History API Using the Web speech API Using web workers All All web technology Technologies Accessibility HTTP URI Web extensions WebAssembly WebDriver See all… Topics Media Performance Privacy Security Progressive web apps Learn Learn web development Frontend developer course Getting started modules Core modules MDN Curriculum Check out the video course from Scrimba, our partner Learn HTML Structuring content with HTML module Learn CSS CSS styling basics module CSS layout module Learn JavaScript Dynamic scripting with JavaScript module Tools Discover our tools Playground HTTP Observatory Border-image generator Border-radius generator Box-shadow generator Color format converter Color mixer Shape generator About Get to know MDN better About MDN Advertise with us Community MDN on GitHub Blog Toggle sidebar Web JavaScript Reference Standard built-in objects Object toLocaleString() Theme OS default Light Dark English (US) Remember language Learn more Deutsch English (US) Español Français 日本語 한국어 Português (do Brasil) Русский 中文 (简体) Object.prototype.toLocaleString() Baseline Widely available This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015. Learn more See full compatibility The toLocaleString() method of Object instances returns a string representing this object. This method is meant to be overridden by derived objects for locale-specific purposes. In this article Try it Syntax Description Examples Specifications Browser compatibility See also Try it const date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); console.log(date.toLocaleString("ar-EG")); // Expected output: "٢٠‏/١٢‏/٢٠١٢ ٤:٠٠:٠٠ ص" const number = 123456.789; console.log(number.toLocaleString("de-DE")); // Expected output: "123.456,789" Syntax js toLocaleString() Parameters None. However, all objects that override this method are expected to accept at most two parameters, corresponding to locales and options, such as Number.prototype.toLocaleString. The parameter positions should not be used for any other purpose. Return value The return value of calling this.toString(). Description All objects that inherit from Object.prototype (that is, all except null-prototype objects) inherit the toLocaleString() method. Object's toLocaleString returns the result of calling this.toString(). This function is provided to give objects a generic toLocaleString method, even though not all may use it. In the core language, these built-in objects override toLocaleString to provide locale-specific formatting: Array: Array.prototype.toLocaleString() Number: Number.prototype.toLocaleString() Date: Date.prototype.toLocaleString() TypedArray: TypedArray.prototype.toLocaleString() BigInt: BigInt.prototype.toLocaleString() Examples Using the base toLocaleString() method The base toLocaleString() method simply calls toString(). js const obj = { toString() { return "My Object"; }, }; console.log(obj.toLocaleString()); // "My Object" Array toLocaleString() override Array.prototype.toLocaleString() is used to print array values as a string by invoking each element's toLocaleString() method and joining the results with a locale-specific separator. For example: js const testArray = [4, 7, 10]; const euroPrices = testArray.toLocaleString("fr", { style: "currency", currency: "EUR", }); // "4,00 €,7,00 €,10,00 €" Date toLocaleString() override Date.prototype.toLocaleString() is used to print out date displays more suitable for specific locales. For example: js const testDate = new Date(); // "Fri May 29 2020 18:04:24 GMT+0100 (British Summer Time)" const deDate = testDate.toLocaleString("de"); // "29.5.2020, 18:04:24" const frDate = testDate.toLocaleString("fr"); // "29/05/2020, 18:04:24" Number toLocaleString() override Number.prototype.toLocaleString() is used to print out number displays more suitable for specific locales, e.g., with the correct separators. For example: js const testNumber = 2901234564; // "2901234564" const deNumber = testNumber.toLocaleString("de"); // "2.901.234.564" const frNumber = testNumber.toLocaleString("fr"); // "2 901 234 564" Specifications Specification ECMAScript® 2027 Language Specification # sec-object.prototype.tolocalestring Browser compatibility Enable JavaScript to view this browser compatibility table. See also Object.prototype.toString() Help improve MDN Was this page helpful to you? Yes No Learn how to contribute This page was last modified on Jul 20, 2025 by MDN contributors. View this page on GitHub • Report a problem with this content Filter sidebar Clear filter input Standard built-in objects Object Constructor Object() Static methods assign() create() defineProperties() defineProperty() entries() freeze() fromEntries() getOwnPropertyDescriptor() getOwnPropertyDescriptors() getOwnPropertyNames() getOwnPropertySymbols() getPrototypeOf() groupBy() hasOwn() is() isExtensible() isFrozen() isSealed() keys() preventExtensions() seal() setPrototypeOf() values() Instance methods __defineGetter__() __defineSetter__() __lookupGetter__() __lookupSetter__() hasOwnProperty() isPrototypeOf() propertyIsEnumerable() toLocaleString() toString() valueOf() Instance properties __proto__ constructor Inheritance Object/Function Static methods apply() bind() call() toString() [Symbol.hasInstance]() Static properties displayName length name prototype arguments caller Instance methods __defineGetter__() __defineSetter__() __lookupGetter__() __lookupSetter__() hasOwnProperty() isPrototypeOf() propertyIsEnumerable() toLocaleString() toString() valueOf() Instance properties __proto__ constructor MDN Your blueprint for a better internet. MDN About Blog Mozilla careers Advertise with us MDN Plus Product help Contribute MDN Community Community resources Writing guidelines MDN Discord MDN on GitHub Developers Web technologies Learn web development Guides Tutorials Glossary Hacks blog Mozilla Website Privacy Notice Telemetry Settings Legal Community Participation Guidelines Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.