country-to-currency
v3.0.1
Published
Map country codes (ISO 3166-1 alpha-2) to their default currency codes (ISO 4217)
Maintainers
Readme
country-to-currency
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.
Install
npm i country-to-currencyNote: Version 3.x dropped the support to CJS and UMD, in favor of using only EcmaScript Modules (ESM).
Usage
This library exports a default object that maps country codes to currency codes.
👉 Examples available in the folder examples.
TypeScript
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";Browser - without installing anything
<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>NodeJS
// const countryToCurrency = require( 'country-to-currency' ); // v1.x and v2.0.2+
import countryToCurrency from 'country-to-currency'; // v3+
console.log( countryToCurrency[ 'US' ] ); // USDDeno
// 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' ] ); // USDCurrency symbols
Do you also need currency symbols? See how to get them. 💲
Notes
- 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 | Google | | @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|
Contribute
Suggestions? Please open an Issue. Pull Requests? Make sure to edit generate.js instead of index.ts.
License
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.
