country-list
:globe_with_meridians: List of all countries with names and ISO 3166-1 codes in all languages and data formats.
Top Related Projects
Laravel countries and currencies
Countries, Languages & Continents data (capital and currency, native name, calling codes).
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
๐ Discover our global repository of countries, states, and cities! ๐๏ธ Get comprehensive data in JSON, SQL, PSQL, SQLSERVER, MONGODB, SQLITE, XML, YAML, and CSV formats. Access ISO2, ISO3 codes, country code, capital, native language, timezones (for countries), and more. #countries #states #cities
Quick Overview
The umpirsky/country-list repository is a comprehensive collection of country names in various languages and data formats. It provides a simple and efficient way to access country information for use in web applications, databases, and other software projects. The repository is regularly updated and maintained, ensuring accuracy and relevance.
Pros
- Extensive language support with country names available in over 200 languages
- Multiple data formats available, including JSON, YAML, XML, CSV, and more
- Regularly updated to reflect changes in country names and codes
- Easy to integrate into various programming languages and frameworks
Cons
- Large repository size due to the extensive number of files and formats
- May require additional processing for specific use cases or custom formats
- Limited additional country information beyond names and codes
- Potential for inconsistencies across different language translations
Code Examples
- Reading country names in PHP using JSON format:
<?php
$countries = json_decode(file_get_contents('vendor/umpirsky/country-list/data/en/country.json'), true);
foreach ($countries as $code => $name) {
echo "$code: $name\n";
}
- Accessing country names in Python using YAML format:
import yaml
with open('vendor/umpirsky/country-list/data/en/country.yaml', 'r') as file:
countries = yaml.safe_load(file)
for code, name in countries.items():
print(f"{code}: {name}")
- Using country names in JavaScript with a JSON file:
fetch('vendor/umpirsky/country-list/data/en/country.json')
.then(response => response.json())
.then(countries => {
Object.entries(countries).forEach(([code, name]) => {
console.log(`${code}: ${name}`);
});
});
Getting Started
To use the country-list in your project:
-
Install via Composer (for PHP projects):
composer require umpirsky/country-list
-
Or clone the repository:
git clone https://github.com/umpirsky/country-list.git
-
Choose the desired language and format from the
data
directory. -
Import the chosen file into your project and use it as shown in the code examples above.
Competitor Comparisons
Laravel countries and currencies
Pros of countries
- More comprehensive data, including currencies, languages, and timezones
- Actively maintained with regular updates
- Supports multiple data formats (JSON, CSV, XML)
Cons of countries
- Larger file size due to additional data
- More complex structure, potentially requiring more setup
- May be overkill for simple country list needs
Code Comparison
countries:
use PragmaRX\Countries\Package\Countries;
$countries = new Countries();
$allCountries = $countries->all();
country-list:
use Umpirsky\CountryList\CountryList;
$countryList = new CountryList();
$allCountries = $countryList->getList('en');
Key Differences
- countries offers more detailed information about each country
- country-list focuses solely on country names and codes
- countries provides methods for filtering and manipulating data
- country-list is simpler to use for basic country listing needs
Use Cases
- Use countries for applications requiring detailed country information
- Choose country-list for simpler projects needing only basic country data
Community and Support
- countries has more recent updates and active community involvement
- country-list has a longer history but less frequent updates
Integration
- countries may require more setup but offers greater flexibility
- country-list is easier to integrate for basic country listing functionality
Countries, Languages & Continents data (capital and currency, native name, calling codes).
Pros of Countries
- Includes additional data like country codes, currencies, and languages
- Provides data in multiple formats (JSON, CSV, SQL)
- Regularly updated with contributions from the community
Cons of Countries
- Larger file size due to more comprehensive data
- May require more processing to extract specific information
- Less language/locale support compared to country-list
Code Comparison
country-list:
$countries = Countries::getNames('en');
foreach ($countries as $countryCode => $countryName) {
echo $countryCode . ': ' . $countryName . "\n";
}
Countries:
const countries = require('countries-list').countries;
Object.keys(countries).forEach(code => {
console.log(`${code}: ${countries[code].name}`);
});
Both repositories provide easy-to-use methods for accessing country data, but Countries offers more comprehensive information in various formats. country-list focuses on names and translations, making it lighter and potentially faster for simple use cases. Countries is better suited for applications requiring detailed country information, while country-list excels in multilingual support and simplicity. The choice between them depends on the specific needs of your project, balancing between data completeness and ease of use.
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
Pros of world_countries
- Includes additional data like country codes, calling codes, and TLDs
- Offers data in multiple formats (JSON, CSV, SQL, XML)
- Provides separate files for continents and timezones
Cons of world_countries
- Less comprehensive language support (63 languages vs. 260+)
- Smaller community and fewer contributors
- Less frequent updates
Code Comparison
world_countries (JSON format):
{
"AF": {
"alpha2": "AF",
"alpha3": "AFG",
"name": "Afghanistan",
"numeric": "004",
"official_name": "Islamic Republic of Afghanistan"
}
}
country-list (PHP format):
return array(
'AF' => 'Afghanistan',
'AX' => 'ร
land Islands',
'AL' => 'Albania',
// ...
);
Both repositories provide country data, but they differ in structure and content. world_countries offers more detailed information per country, while country-list focuses on simple key-value pairs of country codes and names.
world_countries is better suited for projects requiring additional country-related data, while country-list excels in multilingual support and simplicity. The choice between the two depends on specific project requirements and the importance of language coverage versus additional country information.
๐ Discover our global repository of countries, states, and cities! ๐๏ธ Get comprehensive data in JSON, SQL, PSQL, SQLSERVER, MONGODB, SQLITE, XML, YAML, and CSV formats. Access ISO2, ISO3 codes, country code, capital, native language, timezones (for countries), and more. #countries #states #cities
Pros of countries-states-cities-database
- Includes more detailed data: states, cities, and additional information like latitude/longitude
- Offers multiple data formats: JSON, SQL, CSV, and XML
- Regularly updated with community contributions
Cons of countries-states-cities-database
- Larger file size due to more comprehensive data
- May require more processing for simple country-only use cases
- Less language support compared to country-list
Code Comparison
countries-states-cities-database (JSON format):
{
"name": "Afghanistan",
"iso3": "AFG",
"iso2": "AF",
"numeric_code": "004",
"phone_code": "93",
"capital": "Kabul",
"currency": "AFN",
"currency_name": "Afghan afghani",
"currency_symbol": "ุ",
"tld": ".af",
"native": "ุงูุบุงูุณุชุงู",
"region": "Asia",
"subregion": "Southern Asia",
"timezones": [...]
}
country-list (PHP format):
return array(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
// ...
);
The countries-states-cities-database provides more comprehensive data per country, while country-list offers a simpler key-value pair structure focused solely on country codes and names.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
symfony upgrade fixer โข twig gettext extractor โข wisdom โข centipede โข permissions handler โข extraload โข gravatar โข locurro โข country list โข transliterator
Country List
List of all countries with names and ISO 3166-1 codes in all languages and all data formats.
Install
composer require umpirsky/country-list
Formats Available
- Text
- JSON
- YAML
- XML
- HTML
- CSV
- SQL
- MySQL
- PostgreSQL
- SQLite
- PHP
- XLIFF
If you intend to use the package with PHP see this.
Multilingual
All formats are also available in multiple languages, please find full language list here.
Build
Country list is available out of the box, but if you want to submit patches, add new formats, update data source or contribute in any other way, you will probably want to rebuild the list:
$ docker-compose run php /var/www/html/bin/build -v
If you need to install composer, get it from https://getcomposer.org/ installation instructions can be found here: https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
Other Interesting Lists
Top Related Projects
Laravel countries and currencies
Countries, Languages & Continents data (capital and currency, native name, calling codes).
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
๐ Discover our global repository of countries, states, and cities! ๐๏ธ Get comprehensive data in JSON, SQL, PSQL, SQLSERVER, MONGODB, SQLITE, XML, YAML, and CSV formats. Access ISO2, ISO3 codes, country code, capital, native language, timezones (for countries), and more. #countries #states #cities
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot