Yes remove the commas:

let output = parseFloat("2,299.00".replace(/,/g, ''));
console.log(output);

Answer from Sam on Stack Overflow
🌐
Codingexercises
codingexercises.com › format-a-number-with-a-comma-as-a-thousands-separator-js
Format a number with comma as a thousands separator in JS
January 12, 2021 - In JS, we can add a comma as thousands separator using the toLocaleString() method, or using Intl.NumberFormat().format, or using a RegExp. In this tutorial, we'll cover the first two listed means of doing this.
Discussions

JavaScript: Thousand separator / string format - Stack Overflow
Yeah, it's on React Native 0.59 ... of JavaScriptCore (JSC). I'll try again after we update to React Native 0.60+, which includes an update to the JSC. 2020-01-12T23:15:36.67Z+00:00 ... It allows you to change any number in the format you like, with options for decimal digits and separator characters for decimal and thousand... More on stackoverflow.com
🌐 stackoverflow.com
javascript - How can I format a number with commas as thousands separators? - Stack Overflow
I am trying to print an integer in JavaScript with commas as thousands separators. For example, I want to show the number 1234567 as "1,234,567". How would I go about doing this? Here is ... More on stackoverflow.com
🌐 stackoverflow.com
Convert a number with commas as thousands separators
Hi everyone, I am trying to convert a number with commas as thousands separators, so I guess the number shall be converted to a string and then try to apply the format. I have found some JavaScript examples online, but when applying the solution it just converts the number to a string without ... More on forum.knime.com
🌐 forum.knime.com
0
0
June 8, 2021
Thousands Separator
Hi, I have a form with 7 currency fields. The form-filler will input one value, and the other 6 are calculated by javascript. It works & looks good on the form, but the result document doesn't take the formatting with the thousands separator. In the javascript, I'm using .toString() to convert ... More on community.plumsail.com
🌐 community.plumsail.com
0
0
June 19, 2024
🌐
npm
npmjs.com › search
keywords:number separator - npm search
Format thousands with custom separator: 1 000 000 · format · separate · thousands · number · vovanr• 2.0.0 • 5 years ago • 3 dependents • MITpublished version 2.0.0, 5 years ago3 dependents licensed under $MIT · 33,785 · A micro javascript library for formatting numbers with thousands separator ·
Top answer
1 of 15
246

The reference cited in the original answer below was wrong. There is a built in function for this, which is exactly what kaiser suggests below: toLocaleString

So you can do:

(1234567.89).toLocaleString('en')              // for numeric input
parseFloat("1234567.89").toLocaleString('en')  // for string input

The function implemented below works, too, but simply isn't necessary.

(I thought perhaps I'd get lucky and find out that it was necessary back in 2010, but no. According to this more reliable reference, toLocaleString has been part of the standard since ECMAScript 3rd Edition [1999], which I believe means it would have been supported as far back as IE 5.5.)


Original Answer

According to this reference there isn't a built in function for adding commas to a number. But that page includes an example of how to code it yourself:

function addCommas(nStr) {
    nStr += '';
    var x = nStr.split('.');
    var x1 = x[0];
    var x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
            x1 = x1.replace(rgx, '2');
    }
    return x1 + x2;
}

Edit: To go the other way (convert string with commas to number), you could do something like this:

parseFloat("1,234,567.89".replace(/,/g,''))
2 of 15
139

If is about localizing thousands separators, delimiters and decimal separators, go with the following:

// --> numObj.toLocaleString( [locales [, options] ] )
parseInt( number ).toLocaleString();

There are several options you can use (and even locales with fallbacks):

number = 123456.7089;

result  = parseInt( number ).toLocaleString() + "<br>";
result += number.toLocaleString( 'de-DE' ) + "<br>";
result += number.toLocaleString( 'ar-EG' ) + "<br>";
result += number.toLocaleString( 'ja-JP', { 
  style           : 'currency',
  currency        : 'JPY',
  currencyDisplay : 'symbol',
  useGrouping     : true
} ) + "<br>";
result += number.toLocaleString( [ 'jav', 'en' ], { 
  localeMatcher            : 'lookup',
  style                    : 'decimal',
  minimumIntegerDigits     : 2,
  minimumFractionDigits    : 2,
  maximumFractionDigits    : 3,
  minimumSignificantDigits : 2,
  maximumSignificantDigits : 3
} ) + "<br>";

var el = document.getElementById( 'result' );
el.innerHTML = result;
<div id="result"></div>

Details on the MDN info page.

Edit: Commentor @I like Serena adds the following:

To support browsers with a non-English locale where we still want English formatting, use value.toLocaleString('en'). Also works for floating point.

🌐
Byby
byby.dev › js-format-numbers-commas
How to format numbers with commas in JavaScript
In some countries, including many European countries, the comma is used as the decimal separator (eg: 3,14), the period is used as the thousands separator (eg: 1.000.000).
🌐
Phrase
phrase.com › home › resources › blog › how do i convert a decimal to a string with thousands separators?
How Do I Convert a Decimal to a String with Thousands Separators?
January 23, 2025 - This is in JavaScript, but the algorithm can be applied in any language: Split the number into separate characters or strings, one for each digit,
🌐
TutorialsPoint
tutorialspoint.com › article › How-to-print-a-number-with-commas-as-thousands-of-separators-in-JavaScript
How to print a number with commas as thousands of separators in JavaScript?
October 20, 2022 - In this program, the toLocaleString() returns the comma-separated number of the input. <html> <body> <p id="inp"></p> <p id="out"></p> <script> const num = 1234567890; document.getElementById("inp").innerHTML = "Input : " + num; const result = num.toLocaleString('en-US'); document.getElementById("out").innerHTML = "Output: " + result; </script> </body> </html> Intl is the internationalization namespace in JavaScript.
🌐
W3Resource
w3resource.com › javascript-exercises › javascript-math-exercise-39.php
JavaScript Math: Print an integer with commas as thousands separators - w3resource
July 11, 2025 - function thousands_separators(num) { // Convert the number to a string and split it into an array containing the integer part and the decimal part. var num_parts = num.toString().split("."); // Add thousands separators to the integer part using ...
Find elsewhere
🌐
KNIME Community
forum.knime.com › knime analytics platform
Convert a number with commas as thousands separators - KNIME Analytics Platform - KNIME Community Forum
June 8, 2021 - Hi everyone, I am trying to convert a number with commas as thousands separators, so I guess the number shall be converted to a string and then try to apply the format. I have found some JavaScript examples online, but when applying the solution it just converts the number to a string without ...
🌐
CodingTechRoom
codingtechroom.com › question › -parse-number-string-thousands-separators
How to Parse a Number from a String Containing Thousands Separators? - CodingTechRoom
let myString = '1,234,567.89'; ... locales may use different characters for decimal and thousand separators. Use the `replace()` method with a regular expression to remove thousands separators....
🌐
GitHub
gist.github.com › fjaguero › 6932045
JS Regex: Adds thousands separator to a number. · GitHub
This works just fine. "1234567.89" turns into "1.234.567.89" due to the separator is ".", replacing it with "," turns the first value to "1,234,567.89" ... https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString
🌐
npm
npmjs.com › package › parse-decimal-number
parse-decimal-number - npm
August 16, 2017 - var defaultSeparators = {thousands:'.',decimal:','}; ... Numeral.js is good at formatting numbers and comes with an extensive set of locale data that you can use with parse-decimal-number.
      » npm install parse-decimal-number
    
Published   Aug 16, 2017
Version   1.0.0
Author   Andreas Pizsa
🌐
Seanmcp
seanmcp.com › articles › be-careful-parsing-formatted-numbers-in-javascript
Be careful parsing formatted numbers in JavaScript – seanmcp.com
December 20, 2022 - "1,000-2,000" .replace(",", "") .split("-") .map((string) => parseInt(string)); If you're curious, swapping the commas for underscores – the approved numeric separator – doesn't work either:
🌐
Community
community.plumsail.com › forms
Thousands Separator - Forms - Community
June 19, 2024 - Hi, I have a form with 7 currency fields. The form-filler will input one value, and the other 6 are calculated by javascript. It works & looks good on the form, but the result document doesn't take the formatting with the thousands separator. In the javascript, I'm using .toString() to convert ...
🌐
npm
npmjs.com › search
keywords:thousands - npm search
A package for separating numbers in hundreds, thousands, millions, billions and trillions and converts long numbers to readable strings
🌐
Futurestud.io
futurestud.io › tutorials › javascript-use-numeric-separators-for-better-readability
JavaScript — Use Numeric Separators for Better Readability
December 29, 2022 - For example, what about “2014010167“? Is it 20 million, 200 million, or 2 billion? Yeah, we can’t read that number either and need to concentrate. What about “2014010_167”? Much better! JavaScript shipped a new feature called “numeric separator” to improve readability on numbers.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
How to print a number with commas as thousands separators in JavaScript? - GeeksforGeeks
July 12, 2025 - The locales parameter of this object is used to specify the format of the number. The 'en-US' locale is used to specify that the locale takes the format of the United States and the English language, where numbers are represented with a comma between the thousands...