Gathering detailed insights and metrics for world_countries_lists
Gathering detailed insights and metrics for world_countries_lists
Gathering detailed insights and metrics for world_countries_lists
Gathering detailed insights and metrics for world_countries_lists
Constantly updated lists of world countries and their associated alpha-2, alpha-3 and numeric country codes as defined by the ISO 3166 standard, available in CSV, JSON , PHP, SQL and XML formats, in multiple languages and with national flags included; also available are the ISO 3166-2 codes of provinces/ states associated with the countries
npm install world_countries_lists
Typescript
Module System
Node Version
NPM Version
PHP (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
CC-BY-SA-4.0 License
1,462 Stars
421 Commits
386 Forks
47 Watchers
1 Branches
7 Contributors
Updated on Jul 10, 2025
Latest Version
3.2.0
Package Id
world_countries_lists@3.2.0
Unpacked Size
30.98 MB
Size
11.83 MB
File Count
4,780
NPM Version
11.0.0
Node Version
22.12.0
Published on
Jul 01, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
available in multiple languages, in CSV, JSON, PHP, MySQL, MSSQL and XML formats, with associated codes as defined by the ISO 3166 standard, and with national flags included; also available are the ISO 3166-2 codes used for identifying the principal subdivisions (e.g., provinces or states) of all countries coded in ISO 3166-1
Constantly updated lists of world countries, territories and areas of geographical interest, with associated alpha-2, alpha-3 and numeric codes as defined by the ISO 3166-1 standard, published and maintained by the International Organization for Standardization, available in CSV
, JSON
, PHP
, MySQL
, MSSQL
and XML
formats, in multiple languages and with national flags included. Also available are the ISO 3166-2 codes used for identifying the principal subdivisions (e.g., provinces or states) of all countries coded in ISO 3166-1.
In the language folders (inside data/countries
) you will find files named in two different ways:
File names | Content |
---|---|
world.* | Files named like this contain all the 249 countries, territories, and areas of geographical interest that have an officially assigned ISO 3166-1 code. |
countries.* | Files named like this contain the 193 sovereign states (commonly referred to as countries) that are members of the United Nations (UN) . |
Note that there are 206 sovereign states in the world, the 11 states that are missing from the countries list being the ones having their sovereignty disputed. See the list of sovereign states with information on their status and recognition of their sovereignty.
The files contain:
1 for other languages the country names are in that particular language
2 ISO 3166-1 alpha codes are uppercase but this library provides them in lowercase
The lists are currently available in 37 languages:
The language folders are named based on the ISO 639-1 standard.
The project also tries to be a comprehensive and up-to-date source for ISO 3166-2 which defines codes for identifying the principal subdivisions (e.g., provinces or states) of all countries coded in ISO 3166-1.
The purpose of ISO 3166-2 is to establish an international standard of short and unique alphanumeric codes to represent the relevant administrative divisions and dependent territories of all countries in a more convenient and less ambiguous form than their full names. Each complete ISO 3166-2 code consists of two parts, separated by a hyphen:
US-TX
for Texas, USA
The first part is the ISO 3166-1 alpha-2 code of the country; The second part is a string of up to three alphanumeric characters, which is usually obtained from national sources and stems from coding systems already in use in the country concerned, but may also be developed by the ISO itself. Each complete ISO 3166-2 code can then be used to uniquely identify a country subdivision in a global context.
The list is available in CSV
, JSON
, PHP
, MySQL
, MSSQL
and XML
formats in the data/subdivisions
folder and the lists contain:
An excerpt from the CSV file looks like this
1US,US-AL,Alabama,state, 2US,US-AK,Alaska,state, 3US,US-AZ,Arizona,state, 4US,US-AR,Arkansas,state, 5US,US-CA,California,state, 6US,US-CO,Colorado,state,
The country and subdivision data is sourced from Wikipedia's ISO 3166-1 pages and Wikipedia's ISO 3166-2 pages, and is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
The package also contains the national flags of each country in multiple styles. The image files are named using the ISO 3166-1-alpha-2 code of the country they represent, for easily pairing flags with countries.
In /data/flags/default/
you will find 16x16, 24x24, 32x32, 48x48, 64x64 and 128x128 PNG images looking like the ones below. The images were available for free on the now defunct icondrawer.com
In /data/flags/flat/
you will find 16x12, 24x18, 32x24, 48x36, 64x48 and 128x96 PNG images looking like the ones below. The images are taken from the AWESOME https://github.com/lipis/flag-icons.
In /data/flags/flat-waving/
you will find 16x12, 24x18, 32x24, 48x36, 64x48 and 128x96 PNG images looking like the ones below. The images are taken from flagpedia.net
Flag images are also available as single
JSON
files, one for each of the available sizes, containing all flag images asdata-uri
Your support means a lot and it keeps me motivated to keep working on open source projects.
If you like this project please ⭐ it by clicking on the star button at the top of the page.
If you are feeling generous, you can buy me a coffee by donating through PayPal, or you can become a sponsor.
Either way - Thank you! 🎉
The lists are available as a npm package. To install it use:
1# the "--save" argument adds the plugin as a dependency in packages.json 2npm install world_countries_lists --save
You can install the lists via Composer
1composer require stefangabos/world_countries
Alternatively, you can load data from JSDelivr CDN like this:
1<script src="https://cdn.jsdelivr.net/npm/world_countries_lists@latest/data/countries/en/countries.json"></script>
Or
Excerpt from the data/countries/en/countries.sql
file:
(the columns are id
,alpha2
,alpha3
,name
)
1(250,'fr','fra','France'), 2(266,'ga','gab','Gabon'), 3(270,'gm','gmb','Gambia'), 4(268,'ge','geo','Georgia'), 5(276,'de','deu','Germany'), 6(288,'gh','gha','Ghana'), 7(300,'gr','grc','Greece'), 8(308,'gd','grd','Grenada'),
Excerpt from the data/countries/en/countries-mssql.sql
file:
(the columns are id
,alpha2
,alpha3
,name
)
1(250,'fr','fra',N'France'), 2(266,'ga','gab',N'Gabon'), 3(270,'gm','gmb',N'Gambia'), 4(268,'ge','geo',N'Georgia'), 5(276,'de','deu',N'Germany'), 6(288,'gh','gha',N'Ghana'), 7(300,'gr','grc',N'Greece'), 8(308,'gd','grd',N'Grenada'),
Excerpt from the data/countries/en/countries.csv
file:
(the columns are id
,alpha2
,alpha3
,name
)
1250,fr,fra,France 2266,ga,gab,Gabon 3270,gm,gmb,Gambia 4268,ge,geo,Georgia 5276,de,deu,Germany 6288,gh,gha,Ghana 7300,gr,grc,Greece 8308,gd,grd,Grenada
Excerpt from the data/countries/en/countries.json
file:
1{"id":250,"alpha2":"fr","alpha3":"fra","name":"France"}, 2{"id":266,"alpha2":"ga","alpha3":"gab","name":"Gabon"}, 3{"id":270,"alpha2":"gm","alpha3":"gmb","name":"Gambia"}, 4{"id":268,"alpha2":"ge","alpha3":"geo","name":"Georgia"}, 5{"id":276,"alpha2":"de","alpha3":"deu","name":"Germany"}, 6{"id":288,"alpha2":"gh","alpha3":"gha","name":"Ghana"}, 7{"id":300,"alpha2":"gr","alpha3":"grc","name":"Greece"}, 8{"id":308,"alpha2":"gd","alpha3":"grd","name":"Grenada"},
Here's a little helper function for searching for a specific country's data
The helper function assumes that the JSON with the countries data is associated with a variable named
countries
which is in the same scope as the function
The helper function is to be used with the non-combined data sets.
For the combined data sets you can write the function yourself.
1// returns an object with the sought country's data if the search yields a result 2// returns undefined if no results could be found or if argument is incorrect 3function search_country(query) { 4 5 // if argument is not valid return false 6 if (undefined === query.id && undefined === query.alpha2 && undefined === query.alpha3) return undefined; 7 8 // iterate over the array of countries 9 return countries.filter(function(country) { 10 11 // return country's data if 12 return ( 13 // we are searching by ID and we have a match 14 (undefined !== query.id && parseInt(country.id, 10) === parseInt(query.id, 10)) 15 // or we are searching by alpha2 and we have a match 16 || (undefined !== query.alpha2 && country.alpha2 === query.alpha2.toLowerCase()) 17 // or we are searching by alpha3 and we have a match 18 || (undefined !== query.alpha3 && country.alpha3 === query.alpha3.toLowerCase()) 19 ) 20 21 // since "filter" returns an array we use pop to get just the data object 22 }).pop() 23 24}
Usage
1search_country({id: 250}) 2search_country({alpha2: 'fr'}) 3search_country({alpha3: 'fra'})
Typings are available (source):
1import { Country, LanguageCode, TranslatedCountry } from 'world_countries_lists'
Excerpt from the data/countries/en/countries.php
file:
1250 => array('id' => 250, 'alpha2' => 'fr', 'alpha3' => 'fra', 'name' => 'France'), 2266 => array('id' => 266, 'alpha2' => 'ga', 'alpha3' => 'gab', 'name' => 'Gabon'), 3270 => array('id' => 270, 'alpha2' => 'gm', 'alpha3' => 'gmb', 'name' => 'Gambia'),
Here's a little helper function for searching for a specific country's data
The helper function is to be used with the non-combined data sets.
For the combined data sets you can write the function yourself.
1// this function assumes that you have done this: 2$countries = require 'path/to/countries.php'; 3 4// returns an array with the sought country's data if the search yields a result 5// returns false if no results could be found or if argument is incorrect 6function search_country($query) { 7 8 // make the countries available in the function 9 global $countries; 10 11 // if argument is not valid return false 12 if (!isset($query['id']) && !isset($query['alpha2']) && !isset($query['alpha3'])) return false; 13 14 // iterate over the array of countries 15 $result = array_filter($countries, function($country) use ($query) { 16 17 // return country's data if 18 return ( 19 // we are searching by ID and we have a match 20 (isset($query['id']) && $country['id'] == $query['id']) 21 // or we are searching by alpha2 and we have a match 22 || (isset($query['alpha2']) && $country['alpha2'] == strtolower($query['alpha2'])) 23 // or we are searching by alpha3 and we have a match 24 || (isset($query['alpha3']) && $country['alpha3'] == strtolower($query['alpha3'])) 25 ); 26 27 }); 28 29 // since "array_filter" returns an array we use pop to get just the data object 30 // we return false if a result was not found 31 return empty($result) ? false : array_pop($result); 32 33}
Usage
1search_country(array('id' => 250)); 2search_country(array('alpha2' => 'fr')); 3search_country(array('alpha3' => 'fra'));
Excerpt from the data/countries/en/countries.xml
file:
1<country id="250" alpha2="fr" alpha3="fra" name="France"/> 2<country id="266" alpha2="ga" alpha3="gab" name="Gabon"/> 3<country id="270" alpha2="gm" alpha3="gmb" name="Gambia"/> 4<country id="268" alpha2="ge" alpha3="geo" name="Georgia"/> 5<country id="276" alpha2="de" alpha3="deu" name="Germany"/> 6<country id="288" alpha2="gh" alpha3="gha" name="Ghana"/> 7<country id="300" alpha2="gr" alpha3="grc" name="Greece"/> 8<country id="308" alpha2="gd" alpha3="grd" name="Grenada"/>
No vulnerabilities found.
Reason
30 commit(s) and 10 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
no binaries found in the repo
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
no SAST tool detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More