Intl.NumberFormat

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2017.

* Some parts of this feature may have varying levels of support.

Intl.NumberFormat オブジェクトは、言語に依存した数値書式を可能にするオブジェクトのコンストラクターです。

試してみましょう

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 unit
console.log(
  new Intl.NumberFormat("ja-JP", { style: "currency", currency: "JPY" }).format(
    number,
  ),
);
// Expected output: "¥123,457"

// Limit to three significant digits
console.log(
  new Intl.NumberFormat("en-IN", { maximumSignificantDigits: 3 }).format(
    number,
  ),
);
// Expected output: "1,23,000"

コンストラクター

Intl.NumberFormat()

新しい NumberFormat オブジェクトを生成します。

静的メソッド

Intl.NumberFormat.supportedLocalesOf()

提供されたロケールのうち、実行時の既定のロケールにフォールバックせずにサポートされるものを配列に納めて返します。

インスタンスメソッド

Intl.NumberFormat.prototype.format

ゲッター関数で、ローケルに応じて、この NumberFormat オブジェクトのオプションを持つ数値を書式化する関数を返します。

Intl.NumberFormat.prototype.formatToParts()

オブジェクトの Array を返し、これは専用のロケールを意識した書式で使用することができる部品内の数値文字列を表します。

Intl.NumberFormat.prototype.resolvedOptions()

ローケルを反映しているプロパティとオブジェクトの初期化中に計算された照合オプションをもった新しいオブジェクトを返します。

基本的な使用

ローケルを指定しない基本的な使い方では、既定のローケルとオプションで書式化された文字列が返されます。

js
var number = 3500;

console.log(new Intl.NumberFormat().format(number));
// → '3,500' 英語(U.S.)ロケールの場合

locales の使用

この例では、地域による数値書式の違いをいくつか紹介します。アプリケーションのユーザーインターフェイスで使われた言語書式を得るには、言語 (およびフォールバック言語) を locales 引数により指定してください。

js
var number = 123456.789;

// ドイツではカンマを小数、ピリオドを千単位の区切りに用います
console.log(new Intl.NumberFormat("de-DE").format(number));
// → 123.456,789

// ほとんどのアラビア語圏ではアラビア数字を用います
console.log(new Intl.NumberFormat("ar-EG").format(number));
// → ١٢٣٤٥٦٫٧٨٩

// インドでは thousands/lakh/crore 区切りが用いられます
console.log(new Intl.NumberFormat("en-IN").format(number));
// → 1,23,456.789

// nu 拡張キーにより漢数字などの番号方式が使えます
console.log(new Intl.NumberFormat("zh-Hans-CN-u-nu-hanidec").format(number));
// → 一二三,四五六.七八九

// バリ語のようにサポートされないかもしれない言語を用いる場合は
// フォールバック言語を含めます。次の例ではインドネシア語です。
console.log(new Intl.NumberFormat(["ban", "id"]).format(number));
// → 123.456,789

options の使用

options引数を使うと結果をカスタマイズできます。

js
var number = 123456.789;

// 通貨フォーマットを用います
console.log(
  new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(
    number,
  ),
);
// → 123.456,79 €

// 日本円には小数点以下がありません
console.log(
  new Intl.NumberFormat("ja-JP", { style: "currency", currency: "JPY" }).format(
    number,
  ),
);
// → ¥123,457

// 有効数字を3桁に狭めます
console.log(
  new Intl.NumberFormat("en-IN", { maximumSignificantDigits: 3 }).format(
    number,
  ),
);
// → 1,23,000

style と unit の使用

js
console.log(
  new Intl.NumberFormat("pt-PT", {
    style: "unit",
    unit: "mile-per-hour",
  }).format(50),
);
// → 50 mi/h

console.log(
  (16).toLocaleString("en-GB", {
    style: "unit",
    unit: "liter",
    unitDisplay: "long",
  }),
);
// → 16 litres

仕様書

Specification
ECMAScript® 2025 Internationalization API Specification
# numberformat-objects

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
NumberFormat
NumberFormat() constructor
Supports normative optional ChainNumberFormat behavior
locales parameter
options parameter
options.compactDisplay parameter
options.currencyDisplay parameter
options.currencySign parameter
options.currency parameter
options.localeMatcher parameter
options.maximumFractionDigits parameter
options.maximumSignificantDigits parameter
options.minimumFractionDigits parameter
options.minimumIntegerDigits parameter
options.minimumSignificantDigits parameter
options.notation parameter
options.numberingSystem parameter
options.roundingIncrement parameter
options.roundingMode parameter
options.roundingPriority parameter
options.signDisplay parameter
negative value
options.style parameter
options.trailingZeroDisplay parameter
options.unitDisplay parameter
options.unit parameter
options.useGrouping parameter
options.useGrouping parameter accepts: 'always', 'auto', 'min2' (in addition to: true and false)
format
number param string value is decimal (not Number)
formatRange
formatRangeToParts
formatToParts
resolvedOptions
supportedLocalesOf

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
See implementation notes.
Has more compatibility info.

関連情報