Maps country codes (ISO 3166-1 alpha-2) to their default currency codes (ISO 4217).
âš¡ Just 3 KB uncompressed (1.2 KB gzipped), no external dependencies.
🎯 Work with browsers, NodeJS, and DenoJS. JavaScript and TypeScript.
npm i country-to-currencyNote: Version 3.x dropped the support to Universal Module Definition (UMD), in favor of the (modern) EcmaScript Modules (ESM).
This library exports a default object that maps country codes to currency codes.
👉 Examples available in the folder examples.
From version 1.1.0 on, there are two union types available (TypeScript 3.4+ only):
Currencies, that contains all the currencies;Countries, that contains all the countries.
Example using TypeScript on NodeJS:
import countryToCurrency, { Currencies, Countries } from "country-to-currency";<script type="module" >
// import countryToCurrency from "https://unpkg.com/country-to-currency/index.esm.js"; // v2.x
import countryToCurrency from "https://unpkg.com/country-to-currency"; // v3.x
console.log( countryToCurrency[ 'US' ] ); // USD
</script>Example with ESM:
import countryToCurrency from 'country-to-currency';
console.log( countryToCurrency[ 'US' ] ); // USDExample with CJS (require);
// const countryToCurrency = require( 'country-to-currency' ); // v1.x and v2.0.2+
const { default: countryToCurrency } = require( 'country-to-currency' ); // v3+
console.log( countryToCurrency[ 'US' ] ); // USD// import countryToCurrency from "https://unpkg.com/country-to-currency/index.esm.js"; // v2.x
import countryToCurrency from "https://unpkg.com/country-to-currency"; // v3.x
console.log( countryToCurrency[ 'US' ] ); // USDDo you also need currency symbols? See how to get them. 💲
- Total countries:
251- Imported:
249 - Included:
5 - Fixed:
2
- Imported:
- Currencies assumed:
| Country | Currency | Details | Legacy | Thanks to |
|---|---|---|---|---|
Antarctica (AQ) |
USD |
Antarctica has no official currency | @thiagodp | |
Palestine (PS) |
ILS |
@thiagodp | ||
South Georgia and the South Sandwich Islands (GS) |
FKP |
Wikipedia and https://gov.gs | @danielrentz, @thiagodp | |
Netherlands Antilles (AN) |
ANG |
Legacy support. In 2026 Netherlands Antilles was split into separate countries. | Yes | @jayPare, @thiagodp |
El Salvador (SV) |
USD |
Since 2001. Wikipedia | @chaitanya-d, @thiagodp | |
Kosovo (XK) |
EUR |
Wikipedia and Geo Names | @dukesilverr, @thiagodp | |
Buthan (BT) |
BTN |
According to Wikipedia | @thiagodp |
Suggestions? Please open an Issue. Pull Requests? Make sure to edit generate.js instead of index.ts.
This library is inspired by Michael Rhodes' currency-code-map. The current project adds new currencies, fixes, offers support to browsers and DenoJS, updates dependencies, and provides new internal scripts.