Intl.NumberFormat.prototype.format()

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.

El método Intl.NumberFormat.prototype.format() formatea un número de acuerdo con la configuración regional y las opciones de formato de este objeto NumberFormat.

Pruébalo

const amount = 654321.987;

const options1 = { style: "currency", currency: "RUB" };
const numberFormat1 = new Intl.NumberFormat("ru-RU", options1);

console.log(numberFormat1.format(amount));
// Expected output: "654 321,99 ₽"

const options2 = { style: "currency", currency: "USD" };
const numberFormat2 = new Intl.NumberFormat("en-US", options2);

console.log(numberFormat2.format(amount));
// Expected output: "$654,321.99"

Sintaxis

numberFormat.format(number)

Parametros

number

A Number or BigInt to format.

Descripción

The format getter function formats a number into a string according to the locale and formatting options of this NumberFormat object.

Ejemplos

Usando format

Use the format getter function for formatting a single currency value, here for Russia:

js
var options = { style: "currency", currency: "RUB" };
var numberFormat = new Intl.NumberFormat("ru-RU", options);
console.log(numberFormat.format(654321.987));
// → "654 321,99 руб."

Usando format con map

Use the format getter function for formatting all numbers in an array. Note that the function is bound to the NumberFormat from which it was obtained, so it can be passed directly to Array.prototype.map.

js
var a = [123456.789, 987654.321, 456789.123];
var numberFormat = new Intl.NumberFormat("es-ES");
var formatted = a.map(numberFormat.format);
console.log(formatted.join("; "));
// → "123.456,789; 987.654,321; 456.789,123"

Especificaciones

Specification
ECMAScript® 2025 Internationalization API Specification
# sec-intl.numberformat.prototype.format

Compatibilidad con navegadores

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
format
number param string value is decimal (not Number)

Legend

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

Full support
Full support
No support
No support
See implementation notes.

See also