thiagodp/country-to-currency
💵 Maps country codes (ISO 3166-1-alpha-2) to their default currency codes (ISO 4217)
Featured achievements
The project's latest awards
#1 Repository of the month
#1 Repository of the month
#1 Repository of the month
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-currency
Note: 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
NodeJS
// const countryToCurrency = require( 'country-to-currency' ); // v1.x and v2.0.2+
import countryToCurrency from 'country-to-currency'; // v3+
console.log( countryToCurrency[ 'US' ] ); // USD
Deno
// 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
Currency 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 | @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.
Similar Projects
Discover other similar projects and AI models.
📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
Reverse engineer anything with agents, from app behavior down to native binaries.
freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming, and computer science for free.
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core