- Help
- US ZIP code database
How to use the US ZIP code 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 33,791 ZIP areas, the ones the Census Bureau draws on its maps, each with its centre point, city, county, population and time zone. Pro adds the PO box, business and military ZIP codes, 41,685 ZIP codes in all, and more columns. Complete adds who lives there and the outline of every ZIP area.
- 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 counties and cities 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 ZIP codes are stored as text, so 00601 keeps its leading zero. To add a ZIP code’s county or time zone to your own list, put the database on a sheet named Zips and look each ZIP code up:
=XLOOKUP(TEXT(B2,"00000"), Zips!A:A, Zips!H:H, "not found")
- Column H is county_name. Use J for the time zone, or I for the population.
TEXT(B2,"00000")turns a ZIP code your list stores as a number, like 2138, back into 02138.- Opening the CSV instead? Use Data › From Text/CSV and set the zip column to Text, or Excel drops the zeros.
- In Google Sheets, upload the Excel file: its ZIP codes stay text, and the same XLOOKUP works.
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_zip_codes, with the ZIP code as its key, and fills it:
mysql -u you -p yourdb < us-zip-codes-pro-mysql.sql psql -d yourdb -f us-zip-codes-pro-postgresql.sql
Then ask it what you need, such as the ZIP areas within 5 miles of downtown Chicago, nearest first (MySQL 8):
SELECT zip, city, ROUND(ST_Distance_Sphere( POINT(lng, lat), POINT(-87.6298, 41.8781)) / 1609.344, 1) AS miles FROM us_zip_codes WHERE zip_area HAVING miles <= 5 ORDER BY miles;
- A column with several counties separates them with |, in the same order as their shares: 72001|72081 and 99.7|0.3.
- TRUE and FALSE load as booleans. A value the sources don’t have is NULL.
- Loading a new release? Drop the old table first:
DROP TABLE us_zip_codes;
Use the JSON or the ZIP outlines
The JSON file is one array with an object for each ZIP code, under the same names as the CSV columns. Complete adds the outline of each of the 33,791 ZIP areas, as GeoJSON and KML, for maps in QGIS, Google Earth, Leaflet or MapLibre.
- In the JSON, numbers are numbers, ZIP codes are strings, and a missing value is null.
- Each outline carries one property, zip, to join it to the table.
- The outlines are detailed: about 140 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, when HUD’s ZIP code crosswalk changes. 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 ZIP areas the Census Bureau draws. 7,894 ZIP codes have no area of their own: PO box ZIP codes, those of one company or building, and the military’s APO, FPO and DPO ZIP codes. Pro and Complete add them: each at the middle of the census tract that holds most of its addresses, or at the centre of its town, with approximate set to TRUE; the military ones without a location, with military set to TRUE.
The Census Bureau counts people where they live, by ZIP area. A ZIP code without an area has no population of its own, and no land area, density or survey figures either.
county_fips and county_name give the county with most of the ZIP code’s addresses. Pro and Complete list every county it reaches in county_fips_all and county_names_all, with each one’s share of the addresses in county_shares.
Link to geloky.com/data/us-zip-codes 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.
Your first 100 rows are free. Every day.
Free plan, no credit card · See your results on a map before you pay