Open source · free forever

Country, state and city data. Yours to download.

250 countries, 5,300+ states and 150,000+ cities in 12 formats. Linked by ID, updated frequently, maintained in the open.

Coverage varies by release. Check the API statistics and database releases for current data. Read the ODbL-1.0 licence before using the database.

GitHub contributions
Public releases
ODbL-1.0 licence
Sample records · click to drill inIN › MH › Mumbai
Countries250
States5,300+
Cities150,000+
Mumbaicities.json
{
  "id": 133024,
  "name": "Mumbai",
  "state_id": 4008,
  "state_code": "MH",
  "country_id": 101,
  "country_code": "IN",
  "latitude": "19.07283000",
  "longitude": "72.88261000"
}
Schema

Core tables, linked by ID.

Country, state and city IDs link the core records. Some cities have no state link; use a left join to keep them. This simplified view omits other tables and columns, which vary by release and export format.

countries250
idint
namestr
iso2 · iso3str
phonecodestr
currencystr
region_idfk → regions
timezonesobj
states5,300+
idint
namestr
iso2str
country_idfk → countries
typestr
latitude · longitudedec
timezonestr
cities150,000+
idint
namestr
state_idfk → states (nullable)
country_idfk → countries
latitude · longitudedec
timezonestr
wikiDataIdstr

Coverage and place types

This is a worldwide location dataset, not a guarantee that every city or village is listed. City records can represent settlements, neighbourhoods or administrative units; classifications and coverage vary by country and release. Review the place-type definitions before filtering rows for your application.

Keep country and state IDs with city names so places with the same name stay distinct. Check the fields in your chosen release rather than assuming every format has the same columns or every value is populated.

See the CSV-to-SQLite example with null state links →

Download a world cities database.

Choose CSV for city rows in a spreadsheet or an import pipeline, or Parquet for column-based analysis. Need the country → state → city hierarchy together? Choose the nested JSON download or a world database file. The CSV and Parquet buttons below download cities; get the matching country and state files from the source commit for that release.

For SQL, select your database engine: MySQL, PostgreSQL, SQLite and SQL Server have separate exports. Decompress the downloaded file before importing it with your engine’s tools. For a checked CSV import, follow the CSV-to-SQLite guide.

JSONApps and APIsPopular
Download
MySQLImport dumpPopular
Download
PostgreSQLImport dump
Download
SQLiteSingle file
Download
SQL ServerImport dump
Download
MongoDBBSON dump · mongorestorePopular
Download
CSVSpreadsheetsPopular
Download
ParquetColumnar
Download
XMLLegacy systems
Download
YAMLConfig
Download
GeoJSONMaps
Download
TOONToken-oriented notation
Download
JSON and SQL world files include countries, states and cities. Extract the MongoDB archive and restore its BSON files with mongorestore. Other formats link to city files; additional files are on GitHub releases. Need only some fields or countries? Use the Export Tool.
git clone https://github.com/dr5hn/countries-states-cities-database.git
cd countries-states-cities-database
Licensing, in one place
  • Use it in commercial products.
  • Credit CountryStateCity where the data appears.
  • Review applicable share-alike requirements.
Data and data packages: ODbL-1.0Read the licence →
Import country, state and city CSV into SQL with verified example code →

Rather not host it yourself?

The same records as a live API, with search and a change feed. 3,000 free requests a month.