Currency Formatter

Display prices correctly. This script takes a raw number and transforms it into a properly formatted currency string based on locale settings.

US Dollar
-
Euro (DE)
-
Yen (JP)
-

Copy the Script

<script>
var amount = 12345.67;

var formatter = new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD',
});

document.write(formatter.format(amount)); // $12,345.67
</script>

Frequently Asked Questions

Yes. By changing the locale code (e.g., 'de-DE' for Germany) and currency code ('EUR'), the script automatically adjusts the symbol position and decimal separators.

Yes. The `Intl` object is supported in all modern browsers (IE11+). It is the standard way to handle localization.

Yes, but be careful. Modifying input values *while* the user types can cause cursor jumping issues. It is often better to format on `blur` (when they leave the field).