PHPackages                             prophet777/countries - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. prophet777/countries

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

prophet777/countries
====================

List of world countries in JSON, CSV, XML and Yaml

v2.0.2(7y ago)022ODbL-1.0PHPPHP &gt;=5.6.33

Since Jan 12Pushed 7y agoCompare

[ Source](https://github.com/ProPheT777/countries)[ Packagist](https://packagist.org/packages/prophet777/countries)[ Docs](https://mledoze.github.io/countries/)[ RSS](/packages/prophet777-countries/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (2)Versions (16)Used By (0)

World countries in JSON, CSV, XML and YAML.
===========================================

[](#world-countries-in-json-csv-xml-and-yaml)

[![Latest Stable Version](https://camo.githubusercontent.com/bd5ffbee79ab82ff1d15bb93c11b4f6d81d8485c51cd9d794db027823e103ed5/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f776f726c642d636f756e74726965732e7376673f7374796c653d666c6174)](https://www.npmjs.com/package/world-countries)[![Latest Stable Version](https://camo.githubusercontent.com/aff4f6db2a446108e01836a8e989fb4aaad1d7d6253ea92830eb89c1024490a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6c65646f7a652f636f756e74726965732e7376673f7374796c653d666c6174)](https://packagist.org/packages/mledoze/countries)[![License](https://camo.githubusercontent.com/882ee7ca284ef627830091f16ede3a591f10509ecff60025167cc6928494ad6f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6c65646f7a652f636f756e74726965732e7376673f7374796c653d666c6174)](https://opendatacommons.org/licenses/odbl/1.0/)[![Downloads](https://camo.githubusercontent.com/dd9234152fa238c7ee13d9016e01649c1753ff6d1a012c2aaad188a7419df233/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f646d2f776f726c642d636f756e74726965732e7376673f7374796c653d666c6174)](https://www.npmjs.com/package/world-countries)[![Build Status](https://camo.githubusercontent.com/c45caea700006fe67b723e2277a927788519e7999082ce25c15d25d638f8cae8/68747470733a2f2f7472617669732d63692e6f72672f6d6c65646f7a652f636f756e74726965732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mledoze/countries)[![PHP from Packagist](https://camo.githubusercontent.com/9ef625846d85adf683677c8a9366f676bd2233df6bd0214c546277ebb73998da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6c65646f7a652f636f756e74726965732e737667)](https://packagist.org/packages/mledoze/countries)

Countries data
--------------

[](#countries-data)

This repository contains lists of world countries in JSON, CSV and XML. 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`)
- ISO 4217 currency code(s) (`currency`)
- calling code(s) (`callingCode`)
- 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`)
- name of residents (`demonym`)
- landlocked status (`landlocked`)
- land borders (`borders`)
- land area in km² (`area`)
- Emoji flag (`flag`)

#### Additional data

[](#additional-data)

The [data](https://github.com/mledoze/countries/tree/master/data) folder contains additional data such as the countries GeoJSON outlines and flags in SVG format.

Examples
--------

[](#examples)

##### JSON

[](#json)

```
{
	"name": {
		"common": "Austria",
		"official": "Republic of Austria",
		"native": {
			"bar": {
				"official": "Republik Österreich",
				"common": "Österreich"
			}
		}
	},
	"tld": [".at"],
	"cca2": "AT",
	"ccn3": "040",
	"cca3": "AUT",
	"cioc": "AUT",
	"independent": true,
	"status": "officially-assigned",
	"currency": ["EUR"],
	"callingCode": ["43"],
	"capital": ["Vienna"],
	"altSpellings": ["AT", "Osterreich", "Oesterreich"],
	"region": "Europe",
	"subregion": "Western Europe",
	"languages": {
		"bar": "Austro-Bavarian German"
	},
	"translations": {
		"cym": {"official": "Republic of Austria", "common": "Awstria"},
		"deu": {"official": "Republik Österreich", "common": "Österreich"},
		"fra": {"official": "République d'Autriche", "common": "Autriche"},
		"hrv": {"official": "Republika Austrija", "common": "Austrija"},
		"ita": {"official": "Repubblica d'Austria", "common": "Austria"},
		"jpn": {"official": "オーストリア共和国", "common": "オーストリア"},
		"nld": {"official": "Republiek Oostenrijk", "common": "Oostenrijk"},
		"por": {"official": "República da Áustria", "common": "Áustria"},
		"rus": {"official": "Австрийская Республика", "common": "Австрия"},
		"spa": {"official": "República de Austria", "common": "Austria"}
	},
	"latlng": [47.33333333, 13.33333333],
	"demonym": "Austrian",
	"landlocked": true,
	"borders": ["CZE", "DEU", "HUN", "ITA", "LIE", "SVK", "SVN", "CHE"],
	"area": 83871,
	"flag": "\ud83c\udde6\ud83c\uddf9"
}
```

##### GeoJSON and TopoJSON outlines

[](#geojson-and-topojson-outlines)

See an example for Germany: [GeoJSON](https://github.com/mledoze/countries/blob/bb61a1cddfefd09ad5c92ad0a1effbfceba39930/data/deu.geo.json) or [TopoJSON](https://github.com/mledoze/countries/blob/442472de98e80f4a44f1028960dbb0dfb1d942fe/data/deu.topo.json).

##### CSV

[](#csv)

```
"name";"tld";"cca2";"ccn3";"cca3";"currency";"callingCode";"capital";"altSpellings";"region";"subregion";"languages";"translations";"latlng";"demonym";"landlocked";"borders";"area"
⋮
"Aruba,Aruba,Aruba,Aruba,Aruba,Aruba";".aw";"AW";"533";"ABW";"ARU";"AWG";"297";"Oranjestad";"AW";"Americas";"Caribbean";"Dutch,Papiamento";"Aruba,Aruba,Aruba,Aruba,Aruba,Aruba,Aruba,Aruba,アルバ,アルバ,Aruba,Aruba,Aruba,Aruba,Аруба,Аруба,Aruba,Aruba";"12.5,-69.96666666";"Aruban";"";"";"180"
"Afghanistan,Islamic Republic of Afghanistan,جمهوری اسلامی افغانستان,افغانستان,د افغانستان اسلامي جمهوریت,افغانستان,Owganystan Yslam Respublikasy,Owganystan";".af";"AF";"004";"AFG";"AFG";"AFN";"93";"Kabul";"AF,Afġānistān";"Asia";"Southern Asia";"Dari,Pashto,Turkmen";"Islamic Republic of Afghanistan,Affganistan,Islamischen Republik Afghanistan,Afghanistan,République islamique d'Afghanistan,Afghanistan,Islamska Republika Afganistan,Afganistan,Repubblica islamica dell'Afghanistan,Afghanistan,アフガニスタン·イスラム共和国,アフガニスタン,Islamitische Republiek Afghanistan,Afghanistan,República Islâmica do Afeganistão,Afeganistão,Исламская Республика Афганистан,Афганистан,República Islámica de Afganistán,Afganistán";"33,65";"Afghan";"1";"IRN,PAK,TKM,UZB,TJK,CHN";"652230"
"Angola,Republic of Angola,República de Angola,Angola";".ao";"AO";"024";"AGO";"ANG";"AOA";"244";"Luanda";"AO,República de Angola,ʁɛpublika de an'ɡɔla";"Africa";"Middle Africa";"Portuguese";"Republic of Angola,Angola,Republik Angola,Angola,République d'Angola,Angola,Republika Angola,Angola,Repubblica dell'Angola,Angola,アンゴラ共和国,アンゴラ,Republiek Angola,Angola,República de Angola,Angola,Республика Ангола,Ангола,República de Angola,Angola";"-12.5,18.5";"Angolan";"";"COG,COD,ZMB,NAM";"1246700"
⋮
```

##### XML

[](#xml)

```

⋮

```

##### YAML

[](#yaml)

```
- { name: { common: Aruba, official: Aruba, native: { nld: { official: Aruba, common: Aruba }, pap: { official: Aruba, common: Aruba } } }, tld: [.aw], cca2: AW, ccn3: '533', cca3: ABW, cioc: ARU, currency: [AWG], callingCode: ['297'], capital: Oranjestad, altSpellings: [AW], region: Americas, subregion: Caribbean, languages: { nld: Dutch, pap: Papiamento }, translations: { deu: { official: Aruba, common: Aruba }, fra: { official: Aruba, common: Aruba }, hrv: { official: Aruba, common: Aruba }, ita: { official: Aruba, common: Aruba }, jpn: { official: アルバ, common: アルバ }, nld: { official: Aruba, common: Aruba }, por: { official: Aruba, common: Aruba }, rus: { official: Аруба, common: Аруба }, spa: { official: Aruba, common: Aruba } }, latlng: [12.5, -69.96666666], demonym: Aruban, landlocked: false, borders: {  }, area: 180 }
- { name: { common: Afghanistan, official: 'Islamic Republic of Afghanistan', native: { prs: { official: 'جمهوری اسلامی افغانستان', common: افغانستان }, pus: { official: 'د افغانستان اسلامي جمهوریت', common: افغانستان }, tuk: { official: 'Owganystan Yslam Respublikasy', common: Owganystan } } }, tld: [.af], cca2: AF, ccn3: '004', cca3: AFG, cioc: AFG, currency: [AFN], callingCode: ['93'], capital: Kabul, altSpellings: [AF, Afġānistān], region: Asia, subregion: 'Southern Asia', languages: { prs: Dari, pus: Pashto, tuk: Turkmen }, translations: { cym: { official: 'Islamic Republic of Afghanistan', common: Affganistan }, deu: { official: 'Islamischen Republik Afghanistan', common: Afghanistan }, fra: { official: 'République islamique d''Afghanistan', common: Afghanistan }, hrv: { official: 'Islamska Republika Afganistan', common: Afganistan }, ita: { official: 'Repubblica islamica dell''Afghanistan', common: Afghanistan }, jpn: { official: アフガニスタン·イスラム共和国, common: アフガニスタン }, nld: { official: 'Islamitische Republiek Afghanistan', common: Afghanistan }, por: { official: 'República Islâmica do Afeganistão', common: Afeganistão }, rus: { official: 'Исламская Республика Афганистан', common: Афганистан }, spa: { official: 'República Islámica de Afganistán', common: Afganistán } }, latlng: [33, 65], demonym: Afghan, landlocked: true, borders: [IRN, PAK, TKM, UZB, TJK, CHN], area: 652230 }
- { name: { common: Angola, official: 'Republic of Angola', native: { por: { official: 'República de Angola', common: Angola } } }, tld: [.ao], cca2: AO, ccn3: '024', cca3: AGO, cioc: ANG, currency: [AOA], callingCode: ['244'], capital: Luanda, altSpellings: [AO, 'República de Angola', 'ʁɛpublika de an''ɡɔla'], region: Africa, subregion: 'Middle Africa', languages: { por: Portuguese }, translations: { cym: { official: 'Republic of Angola', common: Angola }, deu: { official: 'Republik Angola', common: Angola }, fra: { official: 'République d''Angola', common: Angola }, hrv: { official: 'Republika Angola', common: Angola }, ita: { official: 'Repubblica dell''Angola', common: Angola }, jpn: { official: アンゴラ共和国, common: アンゴラ }, nld: { official: 'Republiek Angola', common: Angola }, por: { official: 'República de Angola', common: Angola }, rus: { official: 'Республика Ангола', common: Ангола }, spa: { official: 'República de Angola', common: Angola } }, latlng: [-12.5, 18.5], demonym: Angolan, landlocked: false, borders: [COG, COD, ZMB, NAM], area: 1246700 }
```

Customising the output
----------------------

[](#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](https://getcomposer.org) 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:

```
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):

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

You can also exclude multiple fields:

```
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`):

```
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:

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

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

```
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
--------

[](#showcase)

Projects using this dataset:

- [REST Countries](https://restcountries.eu/)
- [International Telephone Input](https://intl-tel-input.com/)
- [Telephone JS](https://github.com/lukaswhite/telephones-js)
- [Countries of the World](http://countries.petethompson.net/)
- [Country Prefix Codes For Go](https://github.com/relops/prefixes)
- [Country Info Mapper in Go](https://github.com/pirsquare/country-mapper)
- [Visa requirements in JSON](https://github.com/StrudelInc/visas2)
- [Country picker modal for React Native](https://github.com/xcarpentier/react-native-country-picker-modal)
- [Agnostic Virtual Assistant](https://github.com/ava-ia/core)

How to contribute?
------------------

[](#how-to-contribute)

Please refer to [CONTRIBUTING](https://github.com/mledoze/countries/blob/master/CONTRIBUTING.md).

To do
-----

[](#to-do)

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

Sources
-------

[](#sources)

 for currency codes.

Region and subregion are taken from .

GeoJSON outlines come from [http://thematicmapping.org/downloads/world\_borders.php](http://thematicmapping.org/downloads/world_borders.php).

The rest comes from Wikipedia.

Credits
-------

[](#credits)

Thanks to:

- @Glazz for his help with country calling codes
- @hexorx for his work ()
- @frederik-jacques for the capital cities
- @fayer for the population, geolocation, demonym and area data
- @ancosen for his help with the borders data
- @herrjemand for country names and various fixes
- all the contributors:

License
-------

[](#license)

See [LICENSE](https://github.com/mledoze/countries/blob/master/LICENSE).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 68% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~111 days

Recently: every ~213 days

Total

12

Last Release

2914d ago

Major Versions

1.8.0 → 2.0.02018-02-08

PHP version history (2 changes)1.6.1PHP &gt;=5.4

2.0.0PHP &gt;=5.6.33

### Community

Maintainers

![](https://www.gravatar.com/avatar/2697e85bca7c41cb6166cf78dca3156bdbbe7950189f0b958115201dcd9a919a?d=identicon)[ProPheT777](/maintainers/ProPheT777)

---

Top Contributors

[![mledoze](https://avatars.githubusercontent.com/u/576509?v=4)](https://github.com/mledoze "mledoze (295 commits)")[![yackermann](https://avatars.githubusercontent.com/u/1636116?v=4)](https://github.com/yackermann "yackermann (29 commits)")[![oscerd](https://avatars.githubusercontent.com/u/5106647?v=4)](https://github.com/oscerd "oscerd (14 commits)")[![blumk](https://avatars.githubusercontent.com/u/2436496?v=4)](https://github.com/blumk "blumk (12 commits)")[![Nabela](https://avatars.githubusercontent.com/u/17912441?v=4)](https://github.com/Nabela "Nabela (9 commits)")[![petert82](https://avatars.githubusercontent.com/u/3646420?v=4)](https://github.com/petert82 "petert82 (9 commits)")[![paulvollmer](https://avatars.githubusercontent.com/u/235200?v=4)](https://github.com/paulvollmer "paulvollmer (8 commits)")[![emilv](https://avatars.githubusercontent.com/u/1684914?v=4)](https://github.com/emilv "emilv (7 commits)")[![jremes-foss](https://avatars.githubusercontent.com/u/4118513?v=4)](https://github.com/jremes-foss "jremes-foss (6 commits)")[![fayderflorez](https://avatars.githubusercontent.com/u/693342?v=4)](https://github.com/fayderflorez "fayderflorez (6 commits)")[![stevep-arm](https://avatars.githubusercontent.com/u/40239816?v=4)](https://github.com/stevep-arm "stevep-arm (4 commits)")[![hinell](https://avatars.githubusercontent.com/u/8136158?v=4)](https://github.com/hinell "hinell (3 commits)")[![ted451](https://avatars.githubusercontent.com/u/1416024?v=4)](https://github.com/ted451 "ted451 (3 commits)")[![stephenpaulger](https://avatars.githubusercontent.com/u/187240?v=4)](https://github.com/stephenpaulger "stephenpaulger (3 commits)")[![michalvavra](https://avatars.githubusercontent.com/u/20018?v=4)](https://github.com/michalvavra "michalvavra (3 commits)")[![thachhoang](https://avatars.githubusercontent.com/u/1286583?v=4)](https://github.com/thachhoang "thachhoang (3 commits)")[![JayChetty](https://avatars.githubusercontent.com/u/4076353?v=4)](https://github.com/JayChetty "JayChetty (2 commits)")[![jjsaunier](https://avatars.githubusercontent.com/u/1763341?v=4)](https://github.com/jjsaunier "jjsaunier (2 commits)")[![ebeauchamps](https://avatars.githubusercontent.com/u/1823359?v=4)](https://github.com/ebeauchamps "ebeauchamps (2 commits)")[![ricardograca](https://avatars.githubusercontent.com/u/1457035?v=4)](https://github.com/ricardograca "ricardograca (2 commits)")

---

Tags

jsonxmlyamlcountriescsvworld

### Embed Badge

![Health badge](/badges/prophet777-countries/health.svg)

```
[![Health](https://phpackages.com/badges/prophet777-countries/health.svg)](https://phpackages.com/packages/prophet777-countries)
```

###  Alternatives

[mledoze/countries

List of world countries in JSON, CSV, XML and YAML

6.2k699.7k6](/packages/mledoze-countries)[faisalman/simple-excel-php

Easily parse / convert / write between Microsoft Excel XML / CSV / TSV / HTML / JSON / etc formats

582599.4k1](/packages/faisalman-simple-excel-php)[soapbox/laravel-formatter

A formatting library that converts data output between XML, CSV, JSON, TXT, YAML and a few others.

2501.1M12](/packages/soapbox-laravel-formatter)[rodenastyle/stream-parser

PHP Multiformat Streaming Parser

443195.7k2](/packages/rodenastyle-stream-parser)[dracoblue/craur

A lossless xml to json and json to xml converter (and csv/xlsx/yaml). Writing PHP Json/Xml/Csv/Yaml/excel Importers made easy

4643.1k2](/packages/dracoblue-craur)[ee/dataexporter-bundle

Easy export data to CSV, XML, HTML, JSON or XLS

4982.5k](/packages/ee-dataexporter-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
