Published on: 13 May, 2016

How to convert a number value into money format in Javascript?

Tumblr Digg Google Plus

To convert a number value into money format in Javascript can be done easily using Javascript. Firstly you will need to use the built in toFixed function that will return a number value into two decimal point and then using a regular expression to reformat the value.

function moneyFormat(value){
	if (isNaN(Number(value)){return "0.00";}
	return value.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');


How to convert back the formatted money value into number value in Javascript?

If you want to return a number or float value from formatted money value, you can easily using the following regular expression to return the value.

function getMoneyValue(formattedMoney){
	return parseFloat(formattedMoney.replace(/[,]+/g, ""));




There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.