PHPackages                             samayo/country-json - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. samayo/country-json

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

samayo/country-json
===================

A simple but useful data of the world (by country) in JSON formats

v2.2.7(1y ago)1.1k23.4k↓16.7%797[1 issues](https://github.com/samayo/country-json/issues)[3 PRs](https://github.com/samayo/country-json/pulls)MITJavaScriptPHP &gt;=5.3.0CI failing

Since Feb 8Pushed 5mo ago23 watchersCompare

[ Source](https://github.com/samayo/country-json)[ Packagist](https://packagist.org/packages/samayo/country-json)[ Docs](http://github.com/samayo/country-json)[ RSS](/packages/samayo-country-json/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (1)Versions (29)Used By (0)

country-json [![Build Status](https://github.com/samayo/country-json/actions/workflows/validate.yml/badge.svg)](https://travis-ci.org/samayo/country-json)
----------------------------------------------------------------------------------------------------------------------------------------------------------

[](#country-json---)

A simple data of the world (by country) each in JSON format.

### Download

[](#download)

Using npm

```
$ npm install country-json
```

or composer

```
$ composer require samayo/country-json
```

or git

```
$ git clone https://github.com/samayo/country-json
```

### List of contents provided in JSON formats:

[](#list-of-contents-provided-in-json-formats)

- [Country by Name](https://github.com/samayo/country-json/blob/master/src/country-by-name.json)
- [Country by Abbreviation](https://github.com/samayo/country-json/blob/master/src/country-by-abbreviation.json)
- [Country by Alphabet Letters](https://github.com/samayo/country-json/blob/master/src/country-by-alphabet-letters.json)
- [Country by Avg Male Height](https://github.com/samayo/country-json/blob/master/src/country-by-avg-male-height.json)
- [Country by Barcode Prefix](https://github.com/samayo/country-json/blob/master/src/country-by-barcode-prefix.json)
- [Country by Calling Code](https://github.com/samayo/country-json/blob/master/src/country-by-calling-code.json)
- [Country by Capital City](https://github.com/samayo/country-json/blob/master/src/country-by-capital-city.json)
- [Country by Cities](https://github.com/samayo/country-json/blob/master/src/country-by-cities.json)
- [Country by Continent](https://github.com/samayo/country-json/blob/master/src/country-by-continent.json)
- [Country by Coastline](https://github.com/samayo/country-json/blob/master/src/country-by-coastline.json)
- [Country by Currency Name](https://github.com/samayo/country-json/blob/master/src/country-by-currency-name.json)
- [Country by Religion](https://github.com/samayo/country-json/blob/master/src/country-by-religion.json)
- [Country by Currency Code](https://github.com/samayo/country-json/blob/master/src/country-by-currency-code.json)
- [Country by Domain Tld](https://github.com/samayo/country-json/blob/master/src/country-by-domain-tld.json)
- [Country by Driving Side](https://github.com/samayo/country-json/blob/master/src/country-by-driving-side.json)
- [Country by Elevation](https://github.com/samayo/country-json/blob/master/src/country-by-elevation.json)
- [Country by Flag](https://github.com/samayo/country-json/blob/master/src/country-by-flag.json)
- [Country by Geo Coordinates](https://github.com/samayo/country-json/blob/master/src/country-by-geo-coordinates.json)
- [Country by Government Type](https://github.com/samayo/country-json/blob/master/src/country-by-government-type.json)
- [Country by Independence Date](https://github.com/samayo/country-json/blob/master/src/country-by-independence-date.json)
- [Country by Iso Numeric](https://github.com/samayo/country-json/blob/master/src/country-by-iso-numeric.json)
- [Country by Landlocked](https://github.com/samayo/country-json/blob/master/src/country-by-landlocked.json)
- [Country by Languages](https://github.com/samayo/country-json/blob/master/src/country-by-languages.json)
- [Country by Life Expectancy](https://github.com/samayo/country-json/blob/master/src/country-by-life-expectancy.json)
- [Country by National Symbol](https://github.com/samayo/country-json/blob/master/src/country-by-national-symbol.json)
- [Country by National Dish](https://github.com/samayo/country-json/blob/master/src/country-by-national-dish.json)
- [Country by Population Density](https://github.com/samayo/country-json/blob/master/src/country-by-population-density.json)
- [Country by Population](https://github.com/samayo/country-json/blob/master/src/country-by-population.json)
- [Country by Region In World](https://github.com/samayo/country-json/blob/master/src/country-by-region-in-world.json)
- [Country by Surface Area](https://github.com/samayo/country-json/blob/master/src/country-by-surface-area.json)
- [Country by Yearly Average Temperature](https://github.com/samayo/country-json/blob/master/src/country-by-yearly-average-temperature.json)

### Usage

[](#usage)

Examples using various languages on how display/integrate the data.

##### PHP

[](#php)

```
$file = file_get_contents("./src/country-by-capital-city.json");

foreach (json_decode($file, true) as $key => $value) {
  var_dump($value); // { country: 'Afghanistan', city: 'Kabul' ..}
}
```

##### Node.js

[](#nodejs)

```
var cities = require('./src/country-by-capital-city.json')

console.log(cities[0]); // { country: 'Afghanistan', city: 'Kabul' }
```

##### Ruby

[](#ruby)

```
require 'json'

file = File.read('./src/country-by-capital-city.json')
json = JSON.parse(file)

puts json[0] # {"country"=>"Afghanistan", "city"=>"Kabul"}
```

##### Python

[](#python)

```
import yaml

with open('./src/country-by-capital-city.json') as json_file:
    for line in yaml.safe_load(json_file):
        print line # {'country': 'Afghanistan', 'city': 'Kabul'}
```

##### Golang

[](#golang)

```
package main

import (
  "encoding/json"
  "fmt"
  "io/ioutil"
)

func main() {
  data, err := ioutil.ReadFile("path/to/country-by-capital-city.json")
  if err != nil {
    panic(err)
  }

  var entries []struct{ Country, City string }
  if err = json.Unmarshal(data, &entries); err != nil {
    panic(err)
  }

  for _, entry := range entries {
    fmt.Println(entry.Country, entry.City)  # {'country': 'Afghanistan', 'city': 'Kabul'}
  }
}
```

### Contribution

[](#contribution)

Feel free to send a PR to fix, update or add new entry anytime. For non-minor changes (ex: country: name, language, city, independence date..), please include a source, if possible.

### Resources

[](#resources)

- [Processing country-json data with ramda-cli](https://github.com/raine/ramda-cli/wiki/Cookbook#playing-around-with-countryjson-data)

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance54

Moderate activity, may be stable

Popularity54

Moderate usage in the ecosystem

Community35

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 60.6% 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 ~131 days

Recently: every ~18 days

Total

22

Last Release

672d ago

Major Versions

1.1.6 → 2.0.02024-03-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/8224efc6c85f9ed635239195b886766f000c05d279ba93124dcc361c235efdf7?d=identicon)[samayo](/maintainers/samayo)

---

Top Contributors

[![samayo](https://avatars.githubusercontent.com/u/5304093?v=4)](https://github.com/samayo "samayo (234 commits)")[![drmonkeyninja](https://avatars.githubusercontent.com/u/357623?v=4)](https://github.com/drmonkeyninja "drmonkeyninja (28 commits)")[![briandfoy](https://avatars.githubusercontent.com/u/22255?v=4)](https://github.com/briandfoy "briandfoy (12 commits)")[![muhashi](https://avatars.githubusercontent.com/u/105213357?v=4)](https://github.com/muhashi "muhashi (11 commits)")[![iamdoubz](https://avatars.githubusercontent.com/u/4871781?v=4)](https://github.com/iamdoubz "iamdoubz (10 commits)")[![raine](https://avatars.githubusercontent.com/u/11027?v=4)](https://github.com/raine "raine (8 commits)")[![Vheissu](https://avatars.githubusercontent.com/u/368330?v=4)](https://github.com/Vheissu "Vheissu (8 commits)")[![techgaun](https://avatars.githubusercontent.com/u/1886670?v=4)](https://github.com/techgaun "techgaun (6 commits)")[![alanpallath](https://avatars.githubusercontent.com/u/17932700?v=4)](https://github.com/alanpallath "alanpallath (6 commits)")[![Kishiko](https://avatars.githubusercontent.com/u/29162210?v=4)](https://github.com/Kishiko "Kishiko (6 commits)")[![awwsmm](https://avatars.githubusercontent.com/u/29188350?v=4)](https://github.com/awwsmm "awwsmm (5 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (5 commits)")[![Arsfiqball](https://avatars.githubusercontent.com/u/6008319?v=4)](https://github.com/Arsfiqball "Arsfiqball (4 commits)")[![Husniddin](https://avatars.githubusercontent.com/u/3638439?v=4)](https://github.com/Husniddin "Husniddin (4 commits)")[![AnupeshVerma](https://avatars.githubusercontent.com/u/77433959?v=4)](https://github.com/AnupeshVerma "AnupeshVerma (4 commits)")[![Z-Fikar](https://avatars.githubusercontent.com/u/13853515?v=4)](https://github.com/Z-Fikar "Z-Fikar (3 commits)")[![ava7](https://avatars.githubusercontent.com/u/1859550?v=4)](https://github.com/ava7 "ava7 (3 commits)")[![BossBele](https://avatars.githubusercontent.com/u/28963165?v=4)](https://github.com/BossBele "BossBele (3 commits)")[![ImOlli](https://avatars.githubusercontent.com/u/20519979?v=4)](https://github.com/ImOlli "ImOlli (3 commits)")[![kuldipem](https://avatars.githubusercontent.com/u/2017625?v=4)](https://github.com/kuldipem "kuldipem (3 commits)")

---

Tags

capital-citycitycountriescountrycountry-datacountry-jsoncurrencyindependencejson-formatlanguagepopulationjsondatacountry

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/samayo-country-json/health.svg)

```
[![Health](https://phpackages.com/badges/samayo-country-json/health.svg)](https://phpackages.com/packages/samayo-country-json)
```

###  Alternatives

[justinrainbow/json-schema

A library to validate a json schema.

3.6k334.7M790](/packages/justinrainbow-json-schema)[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k504.8M167](/packages/mtdowling-jmespathphp)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k141.9M929](/packages/jms-serializer)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k92.4M680](/packages/jms-serializer-bundle)[annexare/countries-list

Continents &amp; countries: ISO 3166-1 alpha-2 code, name, ISO 639-1 languages, capital, ISO 4217 currencies (symbols &amp; numeric codes), native name, phone. JSON, CSV and SQL.

1.3k253.6k1](/packages/annexare-countries-list)[colinodell/json5

UTF-8 compatible JSON5 parser for PHP

30525.1M57](/packages/colinodell-json5)

PHPackages © 2026

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