- Help
- US city database
How to use the US city database
Pick a version, download it, and open it in Excel or load it into your database, with the commands to copy. Then get every release for 12 months at the same link.
Updated
Pick a version
Free holds the 32,054 places the Census Bureau counts in the 50 states and DC: every city, town, village and borough, and every CDP, each with its centre point, county, population, time zone and ZIP codes. Pro adds Puerto Rico’s and the Island Areas’ places and 72,492 smaller communities USGS names, 105,117 in all, and more columns: every county, land area, metro area. Complete adds who lives there and the outline of every Census place.
- Free is for any project, commercial ones too, with a link to the database’s page where people can see it.
- Pro and Complete need no link: use them across your organisation, in your websites and apps too.
- Free’s columns come first in Pro and Complete, in the same order, so a formula or a query keeps working when you move up.
- Need ZIP codes and counties too? All three US databases, each in its Complete version, cost $199 together instead of $297.
Download your files
The free version downloads at once: a zip with the CSV, the Excel file and a README. For Pro or Complete, FastSpring’s checkout opens on the page. Once you have paid, the page turns into your download page, and a private link to it comes by email.
- No Geloky account needed. Keep the email: its link is your download page for 12 months.
- Each format downloads on its own, or take them all in one zip.
- Lost the link? Find my downloads sends it again to the email you paid with.
Open it in Excel or Google Sheets
Open the Excel file as it is: its codes and ZIP codes are stored as text. To add each city’s county to your own list, put the database on a sheet named Cities and look each city up by its name and state (Excel 365):
=XLOOKUP(A2&B2, Cities!A:A&Cities!D:D, Cities!G:G, "not found")
- Column G is county_name. Use K for the time zone, J for the population, or M for the ZIP codes.
- In Google Sheets, upload the Excel file and wrap the same formula in
ARRAYFORMULA( ). - Names typed without accents? Look them up in column B, city_ascii: Canon City finds Cañon City.
- A few names repeat within a state: Chevy Chase, Maryland is both a town and a CDP. XLOOKUP returns the first, so check type when it matters.
Load it into a database
The SQL zip holds one file for MySQL and MariaDB, and one for PostgreSQL. Each creates a table named us_cities, with USGS’s id as its key, and fills it:
mysql -u you -p yourdb < us-cities-pro-mysql.sql psql -d yourdb -f us-cities-pro-postgresql.sql
Then ask it what you need, such as the places of 50,000 people or more within 50 miles of Denver, the biggest first (MySQL 8):
SELECT city, population, ROUND(ST_Distance_Sphere( POINT(lng, lat), POINT(-104.9903, 39.7392)) / 1609.344) AS miles FROM us_cities WHERE population > 50000 HAVING miles <= 50 ORDER BY population DESC;
- A column with several values separates them with |: a place’s ZIP codes in zip_codes, its counties in county_fips_all.
- TRUE and FALSE load as booleans. A value the sources don’t have is NULL: a community has no population.
- Loading a new release? Drop the old table first:
DROP TABLE us_cities;
Use the JSON or the place outlines
The JSON file is one array with an object for each place, under the same names as the CSV columns. Complete adds the outline of every Census place, as GeoJSON and KML, for maps in QGIS, Google Earth, Leaflet or MapLibre. The smaller communities have a point, not an outline.
- In the JSON, numbers are numbers, codes and ZIP codes are strings, and a missing value is null.
- Each outline carries gnis_id, place_fips, city and state_id, to join it to the table.
- The outlines are detailed: about 47 MB as GeoJSON. For a web map, simplify them first, with mapshaper for example.
Get each update
For 12 months, every new release comes to the same link, and we email you when one is out. We aim to publish a release every quarter, with the ZIP codes of each place. The Census figures change once a year.
- Your download page lists every release you can get, newest first.
- Bought Pro? Upgrade to Complete on that page for the $50 difference. Your updates keep their end date.
- After the 12 months, everything you downloaded stays yours; only new releases stop.
Free holds the places the Census Bureau counts in the 50 states and DC. Pro and Complete add Puerto Rico’s and the Island Areas’ places and the 72,492 smaller communities USGS names: towns too small for the Census Bureau to count, with their point, county, ZIP code and time zone, but no population.
A census designated place: a community the Census Bureau counts though it has no government of its own, such as Arlington, Virginia, or Honolulu. type says CDP, and incorporated says FALSE.
county_fips is the county the place’s centre lies in. In Pro and Complete, a city across a county line lists every county it lies in, in county_fips_all: New York City’s five, Chicago’s Cook and DuPage.
The ZIP areas sharing at least 5% of their land with the place, or 5% of the place’s, and the PO box and company ZIP codes the Postal Service names after it in its counties. A community gets the ZIP area its point lies in.
Link to geloky.com/data/us-cities from a page people can see where you use the data, such as the page with your map. If you use it only inside your organisation, put the link on your website, on a page people can reach from your home page.
Yes, for your project only. Your whole organisation may use the data, in its websites and apps too, but don’t publish, sell or give away the files themselves. The data licence has the details.
Yes. The API’s city lookup gives the free version’s columns for up to 100 places a call, by name and state or by Census place code, at $0.001 per place found. AI assistants connected to Geloky can use it too.
Your first 100 rows are free. Every day.
Free plan, no credit card · See your results on a map before you pay