Readit News logoReadit News
pseudosavant · 6 months ago
For those that may be interested, this is my project to easily get a list of every zipcode + city/state combo. It is available as JSON you can easily directly work with, or even try a service like this: https://usps-zip-codes.deno.dev/90210.

I have a pet peeve for having to enter my zip code after I've already had to type in the city and state. There wasn't any easily downloadable file that had every ZIP code though. I keep hoping more sites will ask for ZIP first and then just auto fill it using data like this. /wishfulthinking

https://github.com/pseudosavant/usps-zip-codes

stackskipton · 6 months ago
Someone who deals with this, reason you type in the Zip Code is its rudimentary checksum to make sure someone put in right information.

> There wasn't any easily downloadable file that had every ZIP code though

Post Service says what? https://postalpro.usps.com/ZIP_Locale_Detail (Heads up, it's Excel document)

BrandoElFollito · 6 months ago
> reason you type in the Zip Code is its rudimentary checksum to make sure someone put in right information.

I did not know you had a checksum in US zipcodes (I am French, oir zip codes are for the most part "region number"+"number that may tell about the importance of the city or carry a completely different meaning".

78000 is Versailles, which would make the city the "most important" city of the 78 "region", one of the ones around Paris.

78140 is another city, and 78142 (a mde up number) would be some internal numbering in the city, usually linked to a post office and usually unknown to the everyday Joe.

How this gets complicated is fascinating.

pseudosavant · 6 months ago
Nice find! Looks like something they recently added. Before I made this project I was looking for exactly something like that and I couldn't find it anywhere.
Spooky23 · 6 months ago
The only gotcha with the zip code reverse lookup is that there is a many to one relationship between city and zip. Look at Albany, NY (12201-12209) in the list you posted. There are a few with two cities, and iirc there are at least 3 other acceptable cities for 12203 that aren’t listed in that source.
pseudosavant · 6 months ago
Thanks for the heads up on the newer https://postalpro.usps.com/ZIP_Locale_Detail file. I converted my script over to being a Python script that uses ZIP_Locale_Detail.xlsx as the source and doesn't require API access anymore.

My new file contains all of the ZIP + city/state combo from that file now.

dfxm12 · 6 months ago
I have a pet peeve for having to enter my zip code after I've already had to type in the city and state.

What else would you expect? Typing my zip is way easier than going through a list of zipcodes in a dropdown, many of which will be off by one digit in different spots. (ETA: I reread your comment and see what you are expecting)

I like the experience of autocomplete while I'm typing out my street address.

boilerupnc · 6 months ago
I think the sentiment for the pet peeve is commentary on the perceived inefficient sequence of the data input and a hope for reducing the number of fields entered from 3 to 1.

>I have a pet peeve for having to enter my zip code AFTER I've already had to type in the city and state.

The city and state can be derived from the zipcode - so why not simply ask for the zipcode to be typed and then auto-populate the associated city and state.

pseudosavant · 6 months ago
I like the autocomplete too. Probably the best pattern, but it does usually do that by leveraging paid Google Maps APIs I believe.

I was frustrated that this seemingly open data wasn't openly available. Anything that asks for city+state+zipcode can ask for zip code first, auto populate the rest. For the edge cases where the city is wrong, the person can still type in the city like they would have needed to anyway.

It is worth noting that a package would never get delivered to the wrong place because the city wasn't correct but the ZIP code was. The USPS routes based on ZIP codes, not city/state.

uptown · 6 months ago
Your list is very incomplete. It seems to be missing all zip codes with a leading zero.
sib · 6 months ago
I'm a little confused by your peeve:

There are ZIP codes that represent more than one city (town) - and that cross state boundaries.

And there are cities (towns) that have more than one ZIP code.

GuinansEyebrows · 6 months ago
i prefer my device to autofill data i've chosen to save for that purpose into a dumb form 99% of the time over the "start typing your address to locate..." functionality i see on checkout screens these days. maybe someday when they're faster/more transparent, sure, but for now the functionality you reference exists and is not great.
SAI_Peregrinus · 6 months ago
Zip+4 is needed to fill in city+state automatically. But I'd still rather type that first & have city + state auto-fill!

Deleted Comment

jayknight · 6 months ago
It doesn't contain my zipcode/city combination. My zip code spans across a city line, and the json file only has the OTHER city in it.
pseudosavant · 6 months ago
For what it is worth, this is the ZIP code data as according to the USPS. The scripts simply create the JSON file for you by calling the USPS API for every zip code between 00000 and 99999 (plenty of holes in there) and recording the response if there is one.
mixdup · 6 months ago
zip codes are not geographic areas, they are a collection of mail delivery points. Sometimes those points are not geographically contiguous or may overlap
paulsmith · 6 months ago
This is a fact of ZIP Codes that a lot of people stumble one. I've worked on GIS/mapping projects in the past where stakeholders wanted or assumed ZIP Codes to be polygons.

Another complexity that surprises folks is you can't guarantee a one-to-many state-to-ZIP Code relationship. There are several (I forgot offhand how many, I used to have them memorized) that span across state boundaries.

y-c-o-m-b · 6 months ago
Yep, this fact eluded me earlier in the year. I was supposed to map out all ZIP codes in the US and color their boundaries based on certain stats we had. We were surprised to find many areas in the US were empty because they didn't have ZIP codes. I did a quick search and found out ZIP codes are driven by mail routes, and that instantly made sense to me, but the product stakeholders were very surprised to learn it.
chromatin · 6 months ago
My ZIP code happens to be shared by two separate cities and there are a few websites (Github, I'm looking at you) that will fail the payment, registration, etc. attempt if you don't enter the municipality that it THINKS is correct.
ProllyInfamous · 6 months ago
Exact opposite problem at my former rental: Two different properties with different ZIP codes... but they had the same address on the same road, just a mile apart (different jurisdictions).

I lived in a house; the other location was a nail spa. Strangers sometimes visited thinking they were at the right address (they weren't) to get their nails'did (they didn't).

dfxm12 · 6 months ago
Would ZIP+4 help here?
drecoe · 6 months ago
ZCTA[0] can (roughly) be used for this purpose

https://www.census.gov/programs-surveys/geography/guidance/g...

robseed · 6 months ago
And census tools like Geocorr can translate between zip/zcta and other geographies, weighted by population or land area, without doing any spatial calculations.

https://mcdc.missouri.edu/applications/geocorr2022.html

voxadam · 6 months ago
Related:

Stop Using Zip Codes for Geospatial Analysis (2019) - 184 points, 131 comments - https://news.ycombinator.com/item?id=42974728

PLenz · 6 months ago
Sometimes they're entire non geographic entities like the IRS
mulmen · 6 months ago
Or moving areas like aircraft carriers.
Bender · 6 months ago
zip codes are not geographic areas, they are a collection of mail delivery points.

Indeed. My zip is from a neighboring state but has a -xxxx to route specifically to my mail distribution center. Even without the last 4 digits they manage to figure it out, just slower.

bdn_ · 6 months ago
ZIP codes are such interesting identifiers. Their intended use was for facilitating more efficient mail sorting, they were not for providing any sort of human-friendly location data. Yet we still end up using them in so many parts of our lives for identity verification, navigation, population statistics, ...

They remind me of Social Security numbers in a way, where an identifier created for one narrow use (internal Social Security use only) ended up becoming a de facto standard (national identification number) due to the absense of a suitable alternative.

If you'd like to go further down the ZIP code rabbit hole, a few interesting codes to research are `00501`, `48222`, and `12345`. :)

sib · 6 months ago
I find it interesting that we use them to represent areas while they were only intended to represent routes...

And this relates to why there are some ZIP codes that are in multiple states.

SAI_Peregrinus · 6 months ago
Physical routes tend to end in contiguous areas. It's rather difficult to teleport a mail delivery truck.
cptskippy · 6 months ago
ZIP codes are the route a mail truck takes to deliver mail. That mail truck begins and ends it's route at a specific Post Office. The +4 portion of the ZIP code denotes where along the route something is such that mail can be sorted in the order it will be encountered along the route.

So a ZIP code is an area. A ZIP code is often used incorrectly to apply other demographic information such as race or income, those are generalizations and not necessarily 100% accurate.

layman51 · 6 months ago
Another interesting one is `10022-7463` which is commonly communicated as "10022-SHOE" because of how the letters are represented on a U.S. telephone keypad. This is the floor the houses the shoe department of a store, Saks Fifth Avenue.
SnoJohn · 6 months ago
10048
dylan604 · 6 months ago
The classic 90210
cogman10 · 6 months ago
If you find this interesting and you haven't watched it, Go watch "The hidden pattern in post codes" [1]

[1] https://www.youtube.com/watch?v=1K5oDtVAYzk

Leftium · 6 months ago
Thought it was going to be this (from 17 years ago):

- https://www.benfry.com/zipdecode/

- https://hw.leftium.com/#/item/446666

Of course, the results are pretty similar.

---

Another interesting ZIP code visualization: https://eagereyes.org/zipscribble-maps/united-states

serbuvlad · 6 months ago
The + button doesn't work on Firefox (143.0.1; Linux; flatpak; x86-64). The - button works and so do other ways of zooming in (scrolling, double click).
llimllib · 6 months ago
link to the zip code data is broken too; https://public.opendatasoft.com/explore/assets/us-zip-code-l... 404s

Even when I worked for Medicare I couldn't get the damned post office to give us accurate zip code data! It's terrible geodata but also almost everybody remembers it and most zip codes map to one county, so it was the best UI we found for getting a general area for where a person lived.

wombatpm · 6 months ago
Except when it doesn't. 60447 is in three counties in Illinois. Which causes confusion when laws/regulations are applied at a county level.
ninju · 6 months ago
Broken on Chrome 140/Windows 11 as well
joecool1029 · 6 months ago
broken in mobile safari as well.
Dave_Rosenthal · 6 months ago
Neat visualization. There is a street performer in my town that has them all memorized (and many international zip codes as well) and makes a fun show of it, asking people what zip code they are from and putting them on a map. Sometimes it takes him a second to recall the exact town name but he always knows instantly what city they are close to, helped no doubt by the locality of the mapping. Example video:

https://www.youtube.com/watch?v=eSFt38IS0QU

0xTJ · 6 months ago
I'd be very interested in a version of this for Canadian postal code, which have the form K1A 0B1, alternating letters and digits. The first letter is either a province or 1/2 territories, or for Ontario and Quebec is a portion of the province or a metro area. (Vancouver could reasonably be offended at not getting its own first letter.)

Santa Claus's postal code H0H 0H0 would be read as being in the Montreal area (starting with an H), but being rural (second character is a 0). H0 is an almost completely empty prefix, except for an indigenous reserve.