Top Related Projects
Rinvex Country is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.
🌍 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
Countries, Languages & Continents data (capital and currency, native name, calling codes).
:globe_with_meridians: List of all countries with names and ISO 3166-1 codes in all languages and data formats.
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
Quick Overview
The samayo/country-json repository is a collection of JSON files containing various data about countries. It provides information such as country names, capitals, currencies, languages, and more in a simple, easy-to-use JSON format. This project aims to offer a comprehensive and accessible dataset for developers working on applications that require country-related information.
Pros
- Comprehensive data: Covers a wide range of country-related information in a single repository
- Easy to use: Data is provided in JSON format, which is widely supported and easy to parse
- Regular updates: The repository is actively maintained and updated with new information
- Flexible: Can be used in various programming languages and environments
Cons
- Limited data validation: Some entries may contain outdated or incorrect information
- Inconsistent formatting: Some files may have inconsistent data structures or naming conventions
- Lack of versioning: No clear versioning system for tracking changes or updates to the data
- Limited documentation: Minimal explanation of data sources or update frequency
Code Examples
Since this is not a code library but a data repository, there are no specific code examples to provide. However, here's a brief example of how you might use the data in a JavaScript application:
// Fetch country data from the repository
fetch('https://raw.githubusercontent.com/samayo/country-json/master/src/country-by-capital-city.json')
.then(response => response.json())
.then(data => {
// Process the data
console.log(data);
})
.catch(error => console.error('Error:', error));
Getting Started
To use the data from this repository in your project:
- Choose the JSON file(s) you need from the
src
directory of the repository. - Either download the file(s) directly or use the raw GitHub URL to fetch the data in your application.
- Parse the JSON data and use it as needed in your project.
For example, to include country capital data in an HTML file:
<script>
fetch('https://raw.githubusercontent.com/samayo/country-json/master/src/country-by-capital-city.json')
.then(response => response.json())
.then(data => {
const countryList = document.getElementById('country-list');
data.forEach(country => {
const listItem = document.createElement('li');
listItem.textContent = `${country.country}: ${country.city}`;
countryList.appendChild(listItem);
});
});
</script>
<ul id="country-list"></ul>
This example fetches the country-by-capital-city.json file and creates a list of countries and their capitals in an HTML document.
Competitor Comparisons
Rinvex Country is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.
Pros of countries
- More comprehensive data, including detailed information on currencies, languages, and geographical features
- Actively maintained with regular updates and contributions
- Supports multiple data formats (PHP, JSON, YAML) for flexibility
Cons of countries
- Larger file size due to more extensive data, potentially impacting load times
- More complex structure, which may require additional parsing for simple use cases
- Primarily designed for PHP projects, which may limit its usefulness in other environments
Code Comparison
countries:
use Rinvex\Country\Country;
$country = new Country('us');
echo $country->getName(); // United States
echo $country->getCapital(); // Washington, D.C.
country-json:
const countries = require('./countries.json');
const usa = countries.find(country => country.country === 'United States');
console.log(usa.capital); // Washington, D.C.
Summary
countries offers a more comprehensive and actively maintained dataset with support for multiple formats, making it ideal for complex projects requiring detailed country information. However, its larger size and complexity may be overkill for simpler use cases. country-json provides a straightforward JSON structure that's easy to use but lacks the depth and regular updates of countries. The choice between the two depends on the specific needs of your project and the programming environment you're working in.
🌍 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
- More comprehensive data, including states and cities
- Available in multiple formats (JSON, SQL, CSV, XML)
- Regularly updated with community contributions
Cons of countries-states-cities-database
- Larger file size due to more extensive data
- May require more processing for simple country-only queries
- More complex structure, potentially harder to navigate
Code Comparison
countries-states-cities-database:
{
"id": 101,
"name": "India",
"iso3": "IND",
"iso2": "IN",
"numeric_code": "356",
"phone_code": "91",
"capital": "New Delhi",
"currency": "INR",
"currency_name": "Indian rupee",
"currency_symbol": "₹",
"tld": ".in",
"native": "भारत",
"region": "Asia",
"subregion": "Southern Asia",
"timezones": [
{
"zoneName": "Asia/Kolkata",
"gmtOffset": 19800,
"gmtOffsetName": "UTC+05:30",
"abbreviation": "IST",
"tzName": "Indian Standard Time"
}
],
"translations": {
"kr": "인도",
"pt-BR": "Índia",
"pt": "Índia",
"nl": "India",
"hr": "Indija",
"fa": "هند",
"de": "Indien",
"es": "India",
"fr": "Inde",
"ja": "インド",
"it": "India",
"cn": "印度"
},
"latitude": "20.00000000",
"longitude": "77.00000000",
"emoji": "🇮🇳",
"emojiU": "U+1F1EE U+1F1F3"
}
country-json:
{
"country": "India",
"abbreviation": "IN",
"capital": "New Delhi",
"currency": "INR",
"phone": "91",
"population": 1173108018,
"population_density": 356.9,
"area": 3287590
}
Countries, Languages & Continents data (capital and currency, native name, calling codes).
Pros of Countries
- More comprehensive data, including additional fields like capital coordinates, TLDs, and calling codes
- Supports multiple data formats (JSON, CSV, XML) for better flexibility
- Regularly updated with more frequent commits
Cons of Countries
- Larger file size due to more detailed information
- May require more processing for simple use cases
- Less focused on specific country attributes compared to country-json
Code Comparison
Countries:
{
"name": "United States",
"capital": "Washington D.C.",
"currency": "USD",
"phone": "1",
"continent": "NA",
"iso2": "US",
"iso3": "USA",
"tld": ".us"
}
country-json:
{
"country": "United States",
"city": "Washington, D.C."
}
The Countries repository provides more detailed information in a single object, while country-json focuses on specific attributes in separate files. Countries offers a more comprehensive solution for applications requiring extensive country data, whereas country-json is more suitable for simpler use cases or when only specific country information is needed.
Both repositories serve different purposes and can be chosen based on the project requirements, data granularity needs, and preferred data format.
:globe_with_meridians: List of all countries with names and ISO 3166-1 codes in all languages and data formats.
Pros of country-list
- Supports multiple formats (JSON, CSV, SQL, XML, etc.)
- Includes translations for country names in many languages
- Regularly updated with more comprehensive data
Cons of country-list
- Larger file size due to extensive data and multiple formats
- More complex structure, potentially requiring additional parsing
- May include more information than needed for simple use cases
Code Comparison
country-list (JSON format):
{
"AF": {
"name": "Afghanistan",
"alpha2": "AF",
"alpha3": "AFG",
"numeric": "004"
}
}
country-json:
[
{
"country": "Afghanistan",
"alpha2": "AF",
"alpha3": "AFG"
}
]
Summary
country-list offers a more comprehensive dataset with multiple formats and translations, making it suitable for complex international applications. However, this comes at the cost of larger file sizes and potentially more complex implementation.
country-json provides a simpler, more lightweight solution with basic country information in JSON format. It's easier to implement for basic use cases but lacks the extensive features and language support of country-list.
The choice between these repositories depends on the specific requirements of your project, balancing between simplicity and feature richness.
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
- More comprehensive data, including additional fields like ISO numeric codes and official country names
- Available in multiple formats (JSON, XML, CSV, SQL) for easier integration
- Regularly updated with changes to country information
Cons of world_countries
- Larger file size due to more extensive data, potentially impacting load times
- Less granular data organization compared to country-json's multiple files
- May require more processing to extract specific information
Code Comparison
world_countries (JSON format):
{
"name": {
"common": "United States",
"official": "United States of America",
"native": {
"eng": {
"official": "United States of America",
"common": "United States"
}
}
},
"tld": [".us"],
"cca2": "US",
"ccn3": "840",
"cca3": "USA",
"cioc": "USA",
"independent": true,
"status": "officially-assigned",
"currency": ["USD"],
"callingCode": ["1"],
"capital": ["Washington D.C."],
"altSpellings": ["US", "USA", "United States of America"],
"region": "Americas",
"subregion": "North America",
"languages": {
"eng": "English"
},
"translations": {
// ...
},
"latlng": [38, -97],
"demonym": "American",
"landlocked": false,
"borders": ["CAN", "MEX"],
"area": 9629091
}
country-json:
[
{
"country": "United States",
"abbreviation": "US"
}
]
The world_countries repository provides more detailed and structured information, while country-json offers simpler, more focused data sets.
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
country-json 
A simple data of the world (by country) each in JSON format.
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:
- Country by Name
- Country by Abbreviation
- Country by Alphabet Letters
- Country by Avg Male Height
- Country by Barcode Prefix
- Country by Calling Code
- Country by Capital City
- Country by Cities
- Country by Continent
- Country by Coastline
- Country by Currency Name
- Country by Religion
- Country by Currency Code
- Country by Domain Tld
- Country by Driving Side
- Country by Elevation
- Country by Flag
- Country by Geo Coordinates
- Country by Government Type
- Country by Independence Date
- Country by Iso Numeric
- Country by Landlocked
- Country by Languages
- Country by Life Expectancy
- Country by National Symbol
- Country by National Dish
- Country by Population Density
- Country by Population
- Country by Region In World
- Country by Surface Area
- Country by Yearly Average Temperature
Usage
Examples using various languages on how display/integrate the data.
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
var cities = require('./src/country-by-capital-city.json')
console.log(cities[0]); // { country: 'Afghanistan', city: 'Kabul' }
Ruby
require 'json'
file = File.read('./src/country-by-capital-city.json')
json = JSON.parse(file)
puts json[0] # {"country"=>"Afghanistan", "city"=>"Kabul"}
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
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
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
Top Related Projects
Rinvex Country is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.
🌍 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
Countries, Languages & Continents data (capital and currency, native name, calling codes).
:globe_with_meridians: List of all countries with names and ISO 3166-1 codes in all languages and data formats.
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
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