Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

countries-code

nirvana-flame13.7kMIT1.1.1

List of contries data with alpha-2, alpha-3 and number codes

countries, countries name in french, ISO 3166-1, alpha-2 code, alpha-3 code, alpha-2 code to alpha-3 code, alpha-3 code to alpha-2 code, alpha2 to alpha3 code, alpha3 to alpha2 code, alpha-2 code to country name, alpha-3 code to country name, alpha-3 code, 2 Char long country code, 3 Char long country code, getCountry by alphaCode 2 or 3, getCountry by alpha2 or alpha3

readme

countries-code

License Known Vulnerabilities npm

Data fetched from https://unstats.un.org/unsd/methodology/m49/ (UN) and from Wikipedia

List of countries: With country object containing Alpha-2 code (e.g.IE), Alpha-3 code (e.g. IRL), and Number codes.

Example

const countriesQuery = require("countries-code");

console.log(countriesQuery.allCountriesList());
/*
[....,
 {
    "country_name_en": "Ireland",
    "country_name_fr": "Irlande (l')",
    "alpha2": "IE",
    "alpha3": "IRL",
    "number": "372"
},...] 
*/
console.log(countriesQuery.getAllAlphaTwoCodes());
// ["AF",.....]
console.log(countriesQuery.getAllAlphaThreeCodes());
// ["AFG",.....]

// Use getCountry to get country name by alpha code-2 or 3
console.log(countriesQuery.getCountry("IE"));
// "Ireland"
console.log(countriesQuery.getCountry("IRL"));
// "Ireland"

// Use convertAlphaCode to convert alpha code-2 to 3 or vice versa
console.log(countriesQuery.convertAlphaCode("IE"));
// "IRL"
console.log(countriesQuery.convertAlphaCode("IRL"));
// "IE"
import { countriesQuery } from "countries-code";

console.log(countriesQuery.allCountriesList());
/*
[....,
 {
    "country_name_en": "Ireland",
    "country_name_fr": "Irlande (l')",
    "alpha2": "IE",
    "alpha3": "IRL",
    "number": "372"
},...] 
*/
console.log(countriesQuery.getAllAlphaTwoCodes());
// ["AF",.....]
console.log(countriesQuery.getAllAlphaThreeCodes());
// ["AFG",.....]

// Use getCountry to get country name by alpha code-2 or 3
console.log(countriesQuery.getCountry("IE"));
// "Ireland"
console.log(countriesQuery.getCountry("IRL"));
// "Ireland"

// Use convertAlphaCode to convert alpha code-2 to 3 or vice versa
console.log(countriesQuery.convertAlphaCode("IE"));
// "IRL"
console.log(countriesQuery.convertAlphaCode("IRL"));
// "IE"

License

MIT

:incoming_envelope: :four_leaf_clover: