In some cases you may want to show numbers in the same way like Salesforce shows currency in outputField, but you have your value in own variable. Visualforce doesn’t recognise it as a currency and as a result doesn’t add nor currency sign (e.g.$), neither commas after thousands, millions,…

Instead of apex tag outputPanel with value of your variable:

use this one:

It adds 2 decimal places to your number too, if you do not have any, so all numbers will be in the proper format.

If you are calculating currency by Javascript and need the same formatting, add this Javascript function into your page:

This function will add commas into your number, and you can add decimal places with standard Javascript function .toFixed(n) , where ‘n’ is number of decimal places.

In conclusion your line for adding dollar, commas and decimal places to your number will be:

Remember to use this line as the last step before putting value into HTML document, because if you add ‘$’ and commas, it will not be a number but a string, and you can not calculate with a string.