List of major cities of the world (more than 15,000 inhabitants, plus capitals and seats of government of any size), from GeoNames. Each city is identified by its name, country, first-level region (subcountry) and GeoNames id.
Field
Type
Description
name
string
Name of the city (GeoNames name, UTF-8)
country
string
Country name (ISO 3166-1 official short name from pycountry, for example 'Viet Nam'; 'Kosovo' is added by the script)
subcountry
string
ASCII name of the first-level region (state or major administrative area); empty where GeoNames has none
A list of the major cities of the world, with the country and the first-level region each city is in. The data comes from GeoNames.
Column definitions and types are in datapackage.json.
Data
data/world-cities.csv has one row per city. It lists cities with more than 15,000 inhabitants, plus capitals and seats of government, which can be smaller (for example Hamilton, the capital of Bermuda).
Column
Meaning
name
Name of the city (the GeoNames name, in UTF-8, so it can contain accents and non-Latin letters), for example Düsseldorf
country
Country name. These are the ISO 3166-1 official short names, for example Russian Federation, Viet Nam, Bolivia, Plurinational State of. Kosovo is added by the script
subcountry
Name of the first-level region of the country, in ASCII, for example North Rhine-Westphalia. This is a state in the United States, and the major administrative area in other countries. See admin1 on the GeoNames website
geonameid
GeoNames id of the city. This is the primary key
Known limitations
subcountry is empty for cities that have no first-level region in GeoNames. This includes cities that are a whole state, such as Singapore and Vatican City. It is empty, not N/A. By default pandas reads an empty cell as missing (NaN). To keep empty strings instead: pd.read_csv("data/world-cities.csv", keep_default_na=False).
The name of a city is not unique within a country and subcountry. Some combinations of country, subcountry and name appear more than once. Use geonameid to identify a city.
country uses the ISO names, which are not always the everyday names. For example Vatican City is Holy See (Vatican City State).
pycountry: a Python package that gives the ISO 3166-1 country names. It includes the data of the Debian iso-codes project. Licence: LGPL-2.1 (see License).
Changes made to the source data: from cities15000.txt the script keeps only the name, the GeoNames id, the country and the first-level region. The country code is replaced by the country name from pycountry. The first-level region code is replaced by the region's ASCII name from admin1CodesASCII.txt. All other columns (coordinates, population, alternate names, time zone and so on) are removed. The name Kosovo is added by the script for the GeoNames code XK, which pycountry does not know.
Not endorsed by, or affiliated with, GeoNames, pycountry or the iso-codes project.
Preparation
The script needs Python 3.12 and the packages in scripts/requirements.txt (requests, pycountry, pandas and frictionless). Install them and run the script from the repository root:
The script downloads the two GeoNames files and writes data/world-cities.csv.
A GitHub workflow rebuilds the data on the 1st of every month (at 00:00 UTC) and on every push to main. It validates datapackage.json with Frictionless and commits data/world-cities.csv if it changed.
License
The city data comes from GeoNames and is licensed under the Creative Commons Attribution 4.0 International License. If you use it, credit GeoNames with a link, say which licence applies, and say that the data was changed (see the changes listed under Data sources). GeoNames provides the data "as is" without warranty or any representation of accuracy, timeliness or completeness. A link back or credit to Lexman and the Open Knowledge Foundation is also appreciated. See also ATTRIBUTION.txt.
The country names come from pycountry, which is licensed under the LGPL-2.1 and includes iso-codes data (LGPL-2.1-or-later). ISO says its publications are protected by copyright. We could not establish whether this affects short country names, and the LGPL is a software licence. We found nothing that puts LGPL terms on this CSV, so we think the risk is low, but the position is unclear.
All source code is licensed under the MIT licence.
API access
Access dataset files directly from scripts, code, or AI agents.
Each file has a stable URL (r-link) that you can use directly in scripts, apps, or AI agents. These URLs are permanent and safe to hardcode.