# country-locale-map

> Provides mapping between country codes and provides default country locales. Includes optional fuzzy matching for country name.

Latest version **1.9.14** (published 2026-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install country-locale-map
pnpm add country-locale-map
yarn add country-locale-map
bun add country-locale-map
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.9.14 |
| Published | 2026-08-28 |
| First published | 2019-10-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 223.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 49 |
| Author | atnmorrison |
| Maintainers | atnmorrison |
| Keywords | country, locale, alpha, numeric, currency, emoji, fuzzy, capital, ISO-3166, ISO-639 |

## Links

- npm: https://www.npmjs.com/package/country-locale-map
- Repository: https://github.com/atnmorrison/country-locale-map
- Homepage: https://worldcountries.rocketmanmorrison.ca
- Issues: https://github.com/atnmorrison/country-locale-map/issues
- npm.io page: https://npm.io/package/country-locale-map

## Dependencies (1)

- [fuzzball](https://npm.io/package/fuzzball.md) ^2.1.2

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 1.9.14 (latest) — 2026-08-28
- 1.9.13 — 2026-06-11
- 1.9.12 — 2026-01-20
- 1.9.11 — 2025-11-12
- 1.9.10 — 2025-11-12
- 1.9.9 — 2024-11-19
- 1.9.8 — 2024-09-05
- 1.9.7 — 2024-07-10
- 1.9.6 — 2024-07-10
- 1.9.5 — 2024-07-10
- 1.9.4 — 2024-02-28
- 1.9.3 — 2024-02-26
- 1.9.2 — 2024-02-23
- 1.9.1 — 2024-02-23
- 1.9.0 — 2023-12-11
- … 67 more at https://npm.io/package/country-locale-map/versions

## README

# Country Locale Map

Provides easy conversion between country codes and names as well as a default locale for each country. Includes fuzzy matching for country name lookups. 
Methods return undefined if no matches are found 

## Usage

```javascript
const clm = require('country-locale-map');
clm.getAlpha3ByAlpha2('CA'); //returns 'CAN' 
```

If you would like locales to be returned with - instead of_ you can set an environment variable 

CLM_MODE='INTL' in a .env file using [dotenv](https://www.npmjs.com/package/dotenv) just make sure that dotenv is required before requiring the country local map library 

## Functions

### Alpha2 

- getAlpha3ByAlpha2(alpha2)

```javascript
clm.getAlpha3ByAlpha2('CA'); //returns 'CAN' 
```

- getLocaleByAlpha2(alpha2)

```javascript
clm.getLocaleByAlpha2('CA'); //returns 'en_CA' 
```

- getCountryNameByAlpha2(alpha2) 

```javascript
clm.getCountryNameByAlpha2('CA'); //returns 'Canada' 
```

- getNumericByAlpha2(alpha2)

```javascript
clm.getNumericByAlpha2('CA'); //returns '124' 
```

- getCurrencyByAlpha2(alpha2)

```javascript
clm.getCurrencyByAlpha2('CA'); //returns 'CAD' 
```

- getCountryByAlpha2(alpha2)

```javascript
clm.getCountryByAlpha2('CA'); 

/*returns 

    {
        "name":"Canada",
        "alpha2":"CA",
        "alpha3":"CAN",
        "numeric":"124",
        "locales":["en_CA","fr_CA"],
        "default_locale":"en_CA",
        "currency":"CAD",
        "languages":["en","fr"],
        "capital":"Ottawa",
        "emoji":"🇨🇦",
        "emojiU":"U+1F1E8 U+1F1E6",
        "fips":"CA",
        "internet":"CA",
        "continent":"Americas",
        "region":"North America"
    }

*/
```

### Alpha3
- getAlpha2ByAlpha3(alpha3)

```javascript
clm.getAlpha3ByAlpha2('CAN'); //returns 'CA' 
```

- getLocaleByAlpha3(alpha3)

```javascript
clm.getLocaleByAlpha3('CAN'); //returns 'en_CA' 
```

- getCountryNameByAlpha3(alpha3)

```javascript
clm.getCountryNameByAlpha3('CAN'); //returns 'Canada' 
```

- getNumericByAlpha3(alpha3)

```javascript
clm.getNumericByAlpha3('CAN'); //returns '124' 
```

- getCurrencyByAlpha3(alpha3)

```javascript
clm.getCurrencyByAlpha3('CAN'); //returns 'CAD' 
```

- getCountryByAlpha3(alpha3)

```javascript
clm.getCountryByAlpha3('CAN');


/*returns 

    {
        "name":"Canada",
        "alpha2":"CA",
        "alpha3":"CAN",
        "numeric":"124",
        "locales":["en_CA","fr_CA"],
        "default_locale":"en_CA",
        "currency":"CAD",
        "languages":["en","fr"],
        "capital":"Ottawa",
        "emoji":"🇨🇦",
        "emojiU":"U+1F1E8 U+1F1E6",
        "fips":"CA",
        "internet":"CA",
        "continent":"Americas",
        "region":"North America"
    }

*/

```

### Numeric
- getAlpha2ByNumeric(numeric)

```javascript
clm.getAlpha2ByNumeric('123'); //returns 'CA' 
```

- getAlpha3ByNumeric(numeric)

```javascript
clm.getAlpha3ByNumeric('124'); //returns 'CAN' 
```

- getLocaleByNumeric(numeric)

```javascript
clm.getLocaleByNumeric('124'); //returns 'en_CA' 
```

- getCountryNameByNumeric(numeric)

```javascript
clm.getCountryNameByNumeric('124'); //returns 'Canada' 
```

- getCurrencyByNumeric(numeric)

```javascript
clm.getCurrencyByNumeric('124'); //returns 'CAD' 
```

- getCountryByNumeric(numeric) 

```javascript
clm.getCountryByNumeric('124');


/*returns 

    {
        "name":"Canada",
        "alpha2":"CA",
        "alpha3":"CAN",
        "numeric":"124",
        "locales":["en_CA","fr_CA"],
        "default_locale":"en_CA",
        "currency":"CAD",
        "languages":["en","fr"],
        "capital":"Ottawa",
        "emoji":"🇨🇦",
        "emojiU":"U+1F1E8 U+1F1E6",
        "fips":"CA",
        "internet":"CA",
        "continent":"Americas",
        "region":"North America"
    }

*/


```


### Name
- getAlpha2ByName(country, fuzzy) 

```javascript
clm.getAlpha2ByName('Canada'); //returns 'CA' 
```

- getAlpha3ByName(country, fuzzy)

```javascript
clm.getAlpha3ByName('Canada'); //returns 'CAN' 
```

- getLocaleByName(country, fuzzy)

```javascript
clm.getLocaleByName('Canada'); //returns 'en_CA' 
```

- getNumericByName(country, fuzzy)

```javascript
clm.getNumericByName('Canada'); //returns '124' 
```

- getCurrencyByName(country, fuzzy)

```javascript
clm.getCurrencyByName('Canada'); //returns 'CAD' 
```

- getCountryByName(country, fuzzy) 

```javascript
clm.getCountryByName('Canada');

/*returns 

    {
        "name":"Canada",
        "alpha2":"CA",
        "alpha3":"CAN",
        "numeric":"124",
        "locales":["en_CA","fr_CA"],
        "default_locale":"en_CA",
        "currency":"CAD",
        "languages":["en","fr"],
        "capital":"Ottawa",
        "emoji":"🇨🇦",
        "emojiU":"U+1F1E8 U+1F1E6",
        "fips":"CA",
        "internet":"CA",
        "continent":"Americas",
        "region":"North America"
    }

*/

```

if true is passed for fuzzy these functions will do a fuzzy match if it can't find an exact match eg:

```javascript
clm.getCountryByName('Candaa', true);

/*returns 

    {
        "name":"Canada",
        "alpha2":"CA",
        "alpha3":"CAN",
        "numeric":"124",
        "locales":["en_CA","fr_CA"],
        "default_locale":"en_CA",
        "currency":"CAD",
        "languages":["en","fr"],
        "capital":"Ottawa",
        "emoji":"🇨🇦",
        "emojiU":"U+1F1E8 U+1F1E6",
        "fips":"CA",
        "internet":"CA",
        "continent":"Americas",
        "region":"North America"
    }

*/

```

- getAllCountries()

```javascript
clm.getAllCountries();

/*returns 
    the list of all countries 
*/

```
- getCountriesByContinent()

```javascript
clm.getCountriesByContinent("Africa")

/*returns
    the list of africa countries
    [{
      name: 'Algeria',
      alpha2: 'DZ',
      alpha3: 'DZA',
      numeric: '012',
      locales: ["ar_DZ","kab_DZ"],
      default_locale: 'ar_DZ',
      currency: 'DZD',
      latitude: '28.033886',
      longitude: '1.659626',
      currency_name: 'Algerian Dinar',
      languages: ["ar"],
      capital: 'Algiers',
      emoji: '🇩🇿',
      emojiU: 'U+1F1E9 U+1F1FF',
      fips: 'AG',
      internet: 'DZ',
      continent: 'Africa',
      region: 'Northern Africa'      
    }, ...]
*/

```

---
_Source: https://npm.io/package/country-locale-map · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
