Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

countries

> 编程语言
Open source

World countries in JSON, YAML, CSV and XML. Any help is welcome!

6.3K stars0 likes1 views
WebsiteGitHub

About

World countries in JSON, YAML, CSV and XML. Any help is welcome!

World countries in JSON, CSV, XML and YAML.

Countries data

This repository contains a list of world countries, as defined by ISO Standard 3166-1, in JSON, CSV, XML and YAML. Warning: not all entities in this project are independent countries; refer to the independent property to know if the country is considered a sovereign state.

Each line contains the country:

  • name
    • common - common name in english
    • official - official name in english
    • native - list of all native names
      • key: three-letter ISO 639-3 language code
      • value: name object
        • key: official - official name translation
        • key: common - common name translation
  • country code top-level domain (tld)
  • code ISO 3166-1 alpha-2 (cca2)
  • code ISO 3166-1 numeric (ccn3)
  • code ISO 3166-1 alpha-3 (cca3)
  • code International Olympic Committee (cioc)
  • ISO 3166-1 independence status (independent) (denotes the country is considered a sovereign state)
  • ISO 3166-1 assignment status (status)
  • UN Member status (unMember)
  • UN Regional Group (unRegionalGroup)
  • currencies - list of all currencies
    • key: ISO 4217 currency code
    • value: currency object
      • key: name name of the currency
      • key: symbol symbol of the currency
  • International Direct Dialing info (idd)
    • root - the root geographical code prefix. e.g. +6 for New Zealand, +4 for UK.
    • suffixes - list of all suffixes assigned to this country. 4 for NZ, 809, 829, and 849 for Dominican Republic.
  • capital city(ies) (capital)
  • alternative spellings (altSpellings)
  • region
  • subregion
  • list of official languages (languages)
    • key: three-letter ISO 639-3 language code
    • value: name of the language in english
  • list of name translations (translations)
    • key: three-letter ISO 639-3 language code
    • value: name object
      • key: official - official name translation
      • key: common - common name translation
  • latitude and longitude (latlng)
  • demonyms - name of residents, translated & genderized
    • key: three-letter ISO 639-3 language code
    • value: genderized demonym object
      • key: f (female) or m (male)
      • value: genderized demonym translation
  • landlocked status (landlocked)
  • land borders (borders)
  • land area in km² (area)
  • emoji flag (flag)
  • calling codes (callingCodes)

Additional data

The data folder contains additional data such as the countries GeoJSON outlines and flags in SVG format.

Examples

JSON

…

GeoJSON and TopoJSON outlines

See an example for Germany: GeoJSON or TopoJSON.

CSV

…

XML

…

YAML

…

Customising the output

The data files provided in the dist directory include all available fields, but is also possible to build a custom version of the data with certain fields excluded.

To do this, you will first need a working PHP installation, composer and a local copy of this repository. Once you have these, open a terminal in your local version of this project's root directory and run this command to install the necessary dependencies:

bash
composer install

After this finishes, run the following command (here we will exclude the tld field from the output, but you can exclude any field you want):

bash
php countries.php convert --exclude-field=tld

You can also exclude multiple fields:

bash
php countries.php convert --exclude-field=tld --exclude-field=cca2

# Or using the shorter `-x` syntax:
php countries.php convert -x tld -x cca2

If you prefer to include only some fields (this can not be combined with --exclude-field):

bash
php countries.php convert --include-field=name --include-field=area

# or using the shorter `-i` syntax:
php countries.php convert -i name -i area

The generated files are put into the dist directory, but you can change this to another existing directory:

bash
mkdir foobar
php countries.php convert --output-dir=foobar

You can also choose to only generate some of the output formats:

bash
mkdir foobar
php countries.php convert --format=json_unescaped --format=csv

# or using the shorter `-f` syntax:
php countries.php convert -f json_unescaped -f csv

Showcase

Projects using this dataset:

  • REST Countries
  • International Telephone Input
  • Telephone JS
  • Countries of the World
  • Country Prefix Codes For Go
  • Country Info Mapper in Go
  • Visa requirements in JSON
  • Country picker modal for React Native
  • Agnostic Virtual Assistant

How to contribute?

Please refer to CONTRIBUTING.

To do

  • add the type of the country (country, sovereign state, public body, territory, etc.)
  • pull in data automatically from CLDR at build time (idea from @Munter, see #108)

Sources

https://www.currency-iso.org/ for currency codes.

Region and subregion are taken from https://github.com/hexorx/countries.

GeoJSON outlines come from http://thematicmapping.org/downloads/world_borders.php.

The rest comes from Wikipedia.

Credits

Thanks to:

  • @Glazz for his help with country calling codes
  • @hexorx for his work (https://github.com/hexorx/countries)
  • @frederik-jacques for the capital cities
  • @fayer for the population, geolocation, demonym and area data
  • @ancosen for his help with the borders data
  • @yackermann for country names and various fixes
  • all the contributors: https://github.com/mledoze/countries/graphs/contributors

License

See LICENSE.

Flags are not licensed under the ODbL license; see https://en.wikipedia.org/wiki/Wikipedia:Copyright_on_emblems for more information.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPcountriescsvgeojsonjson

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言