Intl.NumberFormat

Intl.NumberFormat.prototype.formatRange

Formats a range of numbers according to the locale and formatting options of this Intl.NumberFormat object

Syntax

JavaScript
numberFormat.formatRange(startRange, endRange)

Parameters

ParameterTypeDescription
startRangenumber | bigintThe start of the range
endRangenumber | bigintThe end of the range

Return Value

A string containing the formatted range

Examples

Basic Usage
const fmt = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' })
console.log(fmt.formatRange(10, 50)) // '$10.00 – $50.00'
Practical Example
const fmt = new Intl.NumberFormat('en-US')
console.log(fmt.formatRange(1000, 5000)) // '1,000–5,000'
Advanced Usage
const fmt = new Intl.NumberFormat('en', {
  style: 'unit',
  unit: 'kilogram'
})
console.log(fmt.formatRange(5, 10)) // '5–10 kg'

Understanding Intl.NumberFormat.prototype.formatRange

The Intl.NumberFormat.prototype.formatRange method in JavaScript formats a range of numbers according to the locale and formatting options of this Intl.NumberFormat object. It belongs to the Intl.NumberFormat object and is one of the most widely used methods for working with intl.numberformat values in modern JavaScript and TypeScript applications.

The method signature is numberFormat.formatRange(startRange, endRange). It accepts 2 parameters: startRange, endRange. When called, it returns a string containing the formatted range. Understanding when and how to use formatRange() helps you write more expressive, readable code.

Common use cases for Intl.NumberFormat.prototype.formatRange include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like intl-numberformat-format, intl-numberformat, intl-datetimeformat-formatrange, enabling you to chain operations together for complex data manipulation pipelines.

Supported in Chrome 106+, Firefox 116+, Safari 15.4+, Edge 106+.

Browser Compatibility

Supported in Chrome 106+, Firefox 116+, Safari 15.4+, Edge 106+.

Related Methods

More Intl.NumberFormat Methods

Other methods in the Intl.NumberFormat object

Related Tools

More Intl.NumberFormat Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.