# iso-countries-lookup

> Find country codes by country names in multiple languages.

Latest version **2.0.8** (published 2023-12-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install iso-countries-lookup
pnpm add iso-countries-lookup
yarn add iso-countries-lookup
bun add iso-countries-lookup
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.8 |
| Published | 2023-12-14 |
| First published | 2019-05-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 3 |
| Unpacked size | 133.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Stephan Georg |
| Maintainers | stephangeorg |
| Keywords | country codes, countries, iso codes, iso country code, ISO 3166, ISO 3166-1 alpha-2, ISO 3166-1 alpha-1 |

## Links

- npm: https://www.npmjs.com/package/iso-countries-lookup
- Repository: https://github.com/StephanGeorg/iso-countries-lookup
- Homepage: https://github.com/StephanGeorg/iso-countries-lookup#readme
- Issues: https://github.com/StephanGeorg/iso-countries-lookup/issues
- npm.io page: https://npm.io/package/iso-countries-lookup

## Dependencies (3)

- [slugify](https://npm.io/package/slugify.md) ^1.6.6
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.23.5
- [i18n-iso-countries](https://npm.io/package/i18n-iso-countries.md) ^7.7.0

## Recent versions

- 2.0.8 (latest) — 2023-12-14
- 2.0.7 — 2022-09-01
- 2.0.6 — 2022-01-31
- 2.0.5 — 2021-10-13
- 2.0.4 — 2021-08-09
- 2.0.3 — 2021-08-09
- 2.0.2 — 2021-08-09
- 2.0.1 — 2021-05-28
- 2.0.0 — 2021-03-19
- 1.1.0 — 2020-09-25
- 1.0.15 — 2020-07-20
- 1.0.14 — 2020-03-26
- 1.0.13 — 2020-03-26
- 1.0.12 — 2019-09-12
- 1.0.11 — 2019-08-27
- … 12 more at https://npm.io/package/iso-countries-lookup/versions

## README

# iso-countries-lookup [![npm version](https://badge.fury.io/js/iso-countries-lookup.svg)](https://badge.fury.io/js/iso-countries-lookup)

Find country codes (ISO 3166-1 alpha-2) by country names in multiple languages with basic fault tolerance for inputs.

Returns the ISO 3166-1 alpha-2 country code for a given country name. Supports [multiple languages](https://www.npmjs.com/package/i18n-iso-countries#supported-languages-iso-639-1) based on [i18n-iso-countries](https://github.com/michaelwittig/node-i18n-iso-countries)
and also alternative names based on [world countries data](https://github.com/mledoze/countries).  

## Installation

```
npm i iso-countries-lookup
```

## Usage

```javascript
import countryCodeLookup from 'iso-countries-lookup';
```

```
countryCodeLookup(input, [options]);
```

```javascript
// Finding ISO Code from official names (fastest)
countryCodeLookup('Germany'); // 'DE'
countryCodeLookup('United States of America'); // 'US'
countryCodeLookup('اليونان'); // 'GR'
countryCodeLookup('罗马尼亚'); // 'RO'
countryCodeLookup('Côte d\'Ivoire'); // 'CI'

// Findinding ISO codes from alternative names
countryCodeLookup('Bundesrepublik Deutschland'); // 'DE'
countryCodeLookup('United states'); // US
countryCodeLookup('Iran'); // 'IR'
countryCodeLookup('Cote dIvoire'); // 'CI'

// Finding ISO codes from dirty strings
countryCodeLookup(', Румыния - '); // Return RO
countryCodeLookup(' , DEU') // DE
countryCodeLookup('uk') // UK

// Finding ISO codes from Numeric
countryCodeLookup(184) // CK
countryCodeLookup('004') // AF

// Finding ISO codes from Numeric
countryCodeLookup(184, { numeric: false }) // undefined
countryCodeLookup('004', { numeric: false }) // undefined

```

## Options

Parameter           | Default             | Description
------------------- | ------------------- | -------------
numeric             | true                | ISO 3166-1 numeric values in input 

## Returns

The [ISO 3166-1 alpha-2 code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of a country or `undefined`.

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