---
title: "Handling Currency in JavaScript"
description: "Using the Intl.NumberFormat API for currency formatting. Practical notes and code examples on Handling Currency in in JS."
url: "https://h3manth.com/scribe/handling-currency-in-javascript/"
canonical_url: "https://h3manth.com/scribe/handling-currency-in-javascript/"
markdown_url: "https://h3manth.com/scribe/blog/handling-currency-in-javascript.md"
publishDate: "2013-06-18T00:00:00.000Z"
author: "Hemanth HM"
category: "javascript"
tags: ["javascript","intl"]
word_count: 89
reading_time_minutes: 1
x_markdown_tokens: 300
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# Handling Currency in JavaScript

> Using the Intl.NumberFormat API for currency formatting. Practical notes and code examples on Handling Currency in in JS.

Handling currency got better with the `Intl` object, which provides a namespace for standard internationalization constructors.

## Intl Constructors

- **Collator**: Language sensitive string comparison
- **DateTimeFormat**: Language sensitive date and time formatting
- **NumberFormat**: Language sensitive number formatting

## Currency Formatting

```javascript
var currency = function(type) {
  return new Intl.NumberFormat(["en-IN"], {
    style: "currency",
    currency: type,
    currencyDisplay: "symbol",
    maximumFractionDigits: 1
  });
};

## Examples
javascript
currency("INR").format(10023.56)
// "Rs10,023.56"

currency("USD").format(10023.56)
// "$10,023.56"

currency("GBP").format(10023.56)
// "£10,023.56"

currency("CNY").format(10023.56)
// "CN¥10,023.56"
```

Hope there shall be a standard API for currency conversion too!
