• Skip to main content
  • Skip to search
  • Skip to select language
HTML

Structure of content on the web

  • Web APIs

    Interfaces for building web applications

  • Learn
    • CSS

      Learn to style content using CSS

    • Overview

      A customized MDN experience

    • FAQ

      Frequently asked questions about MDN Plus

  • HTTP Observatory

    Scan a website for free

  • JavaScript
  • Object.prototype.toLocaleString()
      • Deutsch
      • Español
      • Français
      • 日本語
      • 한국어
      • Português (do Brasil)
      • Русский
      • 中文 (简体)

    In this article

    • Try it
    • Syntax
    • Description
    • Examples
    • Specifications
    • Browser compatibility
    • See also
    1. Object.assign()
    2. Object.entries()
    3. Object.getOwnPropertyDescriptors()
    4. Object.groupBy()
    5. Object.isFrozen()
    6. Object.seal()
    7. Object.prototype.__defineGetter__() Deprecated
    8. Object.prototype.__defineSetter__() Deprecated
    9. Object.prototype.__lookupGetter__() Deprecated
    10. Object.prototype.__lookupSetter__() Deprecated
    11. Object.prototype.toLocaleString()
    12. Object.prototype.__proto__ Deprecated
    13. Function.prototype.bind()
    14. Function: displayName Non-standard
    15. Function.prototype.arguments Non-standard Deprecated
    16. Function.prototype.caller Non-standard Deprecated
  • Instance methods
    1. Object.prototype.__defineGetter__() Deprecated
    2. Object.prototype.__defineSetter__() Deprecated
    3. Object.prototype.__lookupGetter__() Deprecated
    4. Object.prototype.__lookupSetter__() Deprecated
    5. Object.prototype.toLocaleString()
    6. Object.prototype.__proto__ Deprecated
    7. Object instances returns a string representing this object. This method is meant to be overridden by derived objects for locale-specific purposes.

  • Try it

    const date1 = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
    
    console.log(date1.toLocaleString("ar-EG"));
    / Expected output: "٢٠‏/١٢‏/٢٠١٢ ٤:٠٠:٠٠ ص"
    
    const number1 = 123456.789;
    
    console.log(number1.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 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.prototype.toLocaleString()
    • Number.prototype.toLocaleString()
    • Date.prototype.toLocaleString()
    • TypedArray.prototype.toLocaleString()
    • 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® 2026 Language Specification
    # sec-object.prototype.tolocalestring

    Browser compatibility

    See also

    • Object.prototype.toString()

    Help improve MDN

    Intl API provides language sensitive string comparison, number formatting, date and time formatting, and more.","name":"Intl"}},"browserCompat":["javascript.builtins.Object.toLocaleString"],"pageType":"javascript-instance-method"}}

    Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

    Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant