Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

Intl.NumberFormat

BaselineWidely available *

TheIntl.NumberFormat object enables language-sensitive number formatting.

Try it

const number = 123456.789;console.log(  new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(    number,  ),);// Expected output: "123.456,79 €"// The Japanese yen doesn't use a minor unitconsole.log(  new Intl.NumberFormat("ja-JP", { style: "currency", currency: "JPY" }).format(    number,  ),);// Expected output: "¥123,457"// Limit to three significant digitsconsole.log(  new Intl.NumberFormat("en-IN", { maximumSignificantDigits: 3 }).format(    number,  ),);// Expected output: "1,23,000"

Constructor

Intl.NumberFormat()

Creates a newNumberFormat object.

Static methods

Intl.NumberFormat.supportedLocalesOf()

Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.

Instance properties

These properties are defined onIntl.NumberFormat.prototype and shared by allIntl.NumberFormat instances.

Intl.NumberFormat.prototype.constructor

The constructor function that created the instance object. ForIntl.NumberFormat instances, the initial value is theIntl.NumberFormat constructor.

Intl.NumberFormat.prototype[Symbol.toStringTag]

The initial value of the[Symbol.toStringTag] property is the string"Intl.NumberFormat". This property is used inObject.prototype.toString().

Instance methods

Intl.NumberFormat.prototype.format()

Getter function that formats a number according to the locale and formatting options of thisIntl.NumberFormat object.

Intl.NumberFormat.prototype.formatRange()

Getter function that formats a range of numbers according to the locale and formatting options of theIntl.NumberFormat object from which the method is called.

Intl.NumberFormat.prototype.formatRangeToParts()

Returns anArray of objects representing the range of number strings in parts that can be used for custom locale-aware formatting.

Intl.NumberFormat.prototype.formatToParts()

Returns anArray of objects representing the number string in parts that can be used for custom locale-aware formatting.

Intl.NumberFormat.prototype.resolvedOptions()

Returns a new object with properties reflecting the locale and collation options computed during initialization of the object.

Examples

Basic usage

In basic use without specifying a locale, a formatted string in the default locale and with default options is returned.

js
const number = 3500;console.log(new Intl.NumberFormat().format(number));// '3,500' if in US English locale

Using locales

This example shows some of the variations in localized number formats. In order to get the format of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using thelocales argument:

js
const number = 123456.789;// German uses comma as decimal separator and period for thousandsconsole.log(new Intl.NumberFormat("de-DE").format(number));// 123.456,789// Arabic in most Arabic speaking countries uses real Arabic digitsconsole.log(new Intl.NumberFormat("ar-EG").format(number));// ١٢٣٤٥٦٫٧٨٩// India uses thousands/lakh/crore separatorsconsole.log(new Intl.NumberFormat("en-IN").format(number));// 1,23,456.789// the nu extension key requests a numbering system, e.g. Chinese decimalconsole.log(new Intl.NumberFormat("zh-Hans-CN-u-nu-hanidec").format(number));// 一二三,四五六.七八九// when requesting a language that may not be supported, such as// Balinese, include a fallback language, in this case Indonesianconsole.log(new Intl.NumberFormat(["ban", "id"]).format(number));// 123.456,789

Using options

The results can be customized using theoptions argument:

js
const number = 123456.789;// request a currency formatconsole.log(  new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(    number,  ),);// 123.456,79 €// the Japanese yen doesn't use a minor unitconsole.log(  new Intl.NumberFormat("ja-JP", { style: "currency", currency: "JPY" }).format(    number,  ),);// ¥123,457// limit to three significant digitsconsole.log(  new Intl.NumberFormat("en-IN", { maximumSignificantDigits: 3 }).format(    number,  ),);// 1,23,000// Formatting with unitsconsole.log(  new Intl.NumberFormat("pt-PT", {    style: "unit",    unit: "kilometer-per-hour",  }).format(50),);// 50 km/hconsole.log(  (16).toLocaleString("en-GB", {    style: "unit",    unit: "liter",    unitDisplay: "long",  }),);// 16 litres

For an exhaustive list of options, see theIntl.NumberFormat() constructor page.

Specifications

Specification
ECMAScript® 2026 Internationalization API Specification
# numberformat-objects

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp