🌍 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
See the code
A comprehensive, community-maintained dataset of countries, states, counties, cities, and postcodes — published in 12 formats and free under the Open Database License (attribution required).
Total Regions : 6
Total Sub Regions : 22
Total Countries : 250
Total States/Regions/Municipalities : 5,299
Total Cities/Towns/Districts : 153,765
Total Postcodes : 844248 (125 countries)
Total Timezones : 427 (100% IANA coverage)
Last Updated On: October 10, 2026
The two managed products below are the fastest path to shipping. They're actively maintained, billed for sustainability, and back the rest of the ecosystem.
api.countrystatecity.inQuery countries, states, cities, and postcodes from any language. Free tier for prototyping; paid tiers for production.
curl https://api.countrystatecity.in/v1/countries/IN/states/MH/cities \
-H "X-CSCAPI-KEY: $YOUR_API_KEY"
Python applications can use the official sync and async client:
pip install countrystatecity-api
export CSC_API_KEY="YOUR_API_KEY"
from countrystatecity import CountryStateCity
with CountryStateCity() as client:
states = client.get_states_of_country("IN")
print([state["name"] for state in states[:3]])
Get a free API key → · Compare plans · Documentation · Interactive playground · OpenAPI spec · Status
export.countrystatecity.inBuild tailored datasets in your browser — pick country, region, format, and field selection, then download.
Use countrystatecity-api for live, managed data. The suffixed packages are versioned offline snapshots.
| Package | Use | GitHub | PyPI |
|---|---|---|---|
countrystatecity-api | Live REST API client | GitHub | pypi.org |
countrystatecity-countries | Offline snapshot | GitHub | pypi.org |
countrystatecity-timezones | Offline snapshot | GitHub | pypi.org |
countrystatecity-currencies | Offline snapshot | GitHub | pypi.org |
countrystatecity-translations | Offline snapshot | GitHub | pypi.org |
countrystatecity-phonecodes | Offline snapshot | GitHub | pypi.org |
countrystatecity-regions | Offline snapshot | GitHub | pypi.org |
countrystatecity-postal-codes | Offline snapshot | GitHub | pypi.org |
Countries, states, counties, cities, and postcodes are separate datasets. Counties contain official intermediate
administrative units; cities can link to them through a nullable county_id. See
the county field shape and link rules.
Every format ships as a .gz asset on each GitHub Release.
curl -LO https://github.com/dr5hn/countries-states-cities-database/releases/latest/download/json-cities.json.gz
gunzip json-cities.json.gz
curl -LO https://github.com/dr5hn/countries-states-cities-database/releases/latest/download/json-counties.json.gz
gunzip json-counties.json.gz
Smaller reference files (countries, states, counties, schema) live in the repo. Use git clone --depth 1 for a fast clone.
| Format | Export time | Size | Compressed |
|---|---|---|---|
| CSV | 1s | 40 MB | 9 MB |
| MongoDB dump | 1s | 30 MB | 20 MB |
| MySQL SQL | 3s | 86 MB | 22 MB |
| JSON | 4s | 271 MB | 18 MB |
| TOON | 5s | 23 MB | 20 MB |
| Parquet | 7s | 31 MB | 27 MB |
| GeoJSON | 8s | 208 MB | 24 MB |
| XML | 9s | 91 MB | 15 MB |
| YAML | 17s | 68 MB | — |
| SQLite | 45s | 89 MB | — |
The easiest way is the Community Manager — submit corrections through a web UI with end-to-end tracking.
To edit JSON directly:
git clone --depth 1).contributions/cities/, contributions/states/, contributions/countries/, contributions/counties/, or contributions/postcodes/.name, state_id, state_code, country_id, country_code, latitude, longitude. Optional: timezone, wikiDataId, native.id, created_at, updated_at, flag — auto-managed on import.{
"name": "San Francisco",
"state_id": 1416,
"state_code": "CA",
"country_id": 233,
"country_code": "US",
"latitude": "37.77493",
"longitude": "-122.41942",
"timezone": "America/Los_Angeles",
"wikiDataId": "Q62"
}
Contributions guide ·
Contribution guidelines ·
Multi-level territories policy ·
Administrative structure policy ·
The cities.type field
Don't edit the auto-generated directories (
json/,csv/,xml/,yml/,sql/, etc.). They're rebuilt from MySQL on every release.
Licensed under the Open Database License (ODbL v1.0). Commercial use, modification, and redistribution all permitted. Attribution is required, and derivatives must be shared under the same license.
Data by Countries States Cities Database
https://github.com/dr5hn/countries-states-cities-database | ODbL v1.0
If this project saves you time, please consider supporting its continued maintenance.
You can also plant a tree on behalf of the project.
Reach out: gadadarshan [at] gmail [dot] com
Community-maintained data may contain errors or lag behind geopolitical changes. Verify critical data with official sources. Report issues.
(top 24 of 36)
121 followers · starred Dec 2024
405 followers · starred Aug 2024
134 followers · starred Nov 2021
118 followers · starred Mar 2025
🌍 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
See the code
A comprehensive, community-maintained dataset of countries, states, counties, cities, and postcodes — published in 12 formats and free under the Open Database License (attribution required).
Total Regions : 6
Total Sub Regions : 22
Total Countries : 250
Total States/Regions/Municipalities : 5,299
Total Cities/Towns/Districts : 153,765
Total Postcodes : 844248 (125 countries)
Total Timezones : 427 (100% IANA coverage)
Last Updated On: October 10, 2026
The two managed products below are the fastest path to shipping. They're actively maintained, billed for sustainability, and back the rest of the ecosystem.
api.countrystatecity.inQuery countries, states, cities, and postcodes from any language. Free tier for prototyping; paid tiers for production.
curl https://api.countrystatecity.in/v1/countries/IN/states/MH/cities \
-H "X-CSCAPI-KEY: $YOUR_API_KEY"
Python applications can use the official sync and async client:
pip install countrystatecity-api
export CSC_API_KEY="YOUR_API_KEY"
from countrystatecity import CountryStateCity
with CountryStateCity() as client:
states = client.get_states_of_country("IN")
print([state["name"] for state in states[:3]])
Get a free API key → · Compare plans · Documentation · Interactive playground · OpenAPI spec · Status
export.countrystatecity.inBuild tailored datasets in your browser — pick country, region, format, and field selection, then download.
Use countrystatecity-api for live, managed data. The suffixed packages are versioned offline snapshots.
| Package | Use | GitHub | PyPI |
|---|---|---|---|
countrystatecity-api | Live REST API client | GitHub | pypi.org |
countrystatecity-countries | Offline snapshot | GitHub | pypi.org |
countrystatecity-timezones | Offline snapshot | GitHub | pypi.org |
countrystatecity-currencies | Offline snapshot | GitHub | pypi.org |
countrystatecity-translations | Offline snapshot | GitHub | pypi.org |
countrystatecity-phonecodes | Offline snapshot | GitHub | pypi.org |
countrystatecity-regions | Offline snapshot | GitHub | pypi.org |
countrystatecity-postal-codes | Offline snapshot | GitHub | pypi.org |
Countries, states, counties, cities, and postcodes are separate datasets. Counties contain official intermediate
administrative units; cities can link to them through a nullable county_id. See
the county field shape and link rules.
Every format ships as a .gz asset on each GitHub Release.
curl -LO https://github.com/dr5hn/countries-states-cities-database/releases/latest/download/json-cities.json.gz
gunzip json-cities.json.gz
curl -LO https://github.com/dr5hn/countries-states-cities-database/releases/latest/download/json-counties.json.gz
gunzip json-counties.json.gz
Smaller reference files (countries, states, counties, schema) live in the repo. Use git clone --depth 1 for a fast clone.
| Format | Export time | Size | Compressed |
|---|---|---|---|
| CSV | 1s | 40 MB | 9 MB |
| MongoDB dump | 1s | 30 MB | 20 MB |
| MySQL SQL | 3s | 86 MB | 22 MB |
| JSON | 4s | 271 MB | 18 MB |
| TOON | 5s | 23 MB | 20 MB |
| Parquet | 7s | 31 MB | 27 MB |
| GeoJSON | 8s | 208 MB | 24 MB |
| XML | 9s | 91 MB | 15 MB |
| YAML | 17s | 68 MB | — |
| SQLite | 45s | 89 MB | — |
The easiest way is the Community Manager — submit corrections through a web UI with end-to-end tracking.
To edit JSON directly:
git clone --depth 1).contributions/cities/, contributions/states/, contributions/countries/, contributions/counties/, or contributions/postcodes/.name, state_id, state_code, country_id, country_code, latitude, longitude. Optional: timezone, wikiDataId, native.id, created_at, updated_at, flag — auto-managed on import.{
"name": "San Francisco",
"state_id": 1416,
"state_code": "CA",
"country_id": 233,
"country_code": "US",
"latitude": "37.77493",
"longitude": "-122.41942",
"timezone": "America/Los_Angeles",
"wikiDataId": "Q62"
}
Contributions guide ·
Contribution guidelines ·
Multi-level territories policy ·
Administrative structure policy ·
The cities.type field
Don't edit the auto-generated directories (
json/,csv/,xml/,yml/,sql/, etc.). They're rebuilt from MySQL on every release.
Licensed under the Open Database License (ODbL v1.0). Commercial use, modification, and redistribution all permitted. Attribution is required, and derivatives must be shared under the same license.
Data by Countries States Cities Database
https://github.com/dr5hn/countries-states-cities-database | ODbL v1.0
If this project saves you time, please consider supporting its continued maintenance.
You can also plant a tree on behalf of the project.
Reach out: gadadarshan [at] gmail [dot] com
Community-maintained data may contain errors or lag behind geopolitical changes. Verify critical data with official sources. Report issues.
(top 24 of 36)
121 followers · starred Dec 2024
405 followers · starred Aug 2024
134 followers · starred Nov 2021
118 followers · starred Mar 2025