Put the zip code first

379 pointsposted a day ago
by dsalzman

291 Comments

modeless

a day ago

> From those 5 characters you can determine the city, the state, and the country

False. Many zip codes include more than one city, and some even cross multiple states. And you can't always tell the difference between codes from different countries. Now you're not just instantly filling the rest of the form, you're implementing fancy multi-country filtering logic, editable drop downs, etc. Given the obvious incompetence of the people implementing most web forms, you're asking for disaster here.

Instead, learn to use your browser's autofill feature, and design your sites with it in mind. If you do it right the user literally doesn't have to type a single character. That's even better than typing a numeric code. Sadly even this seems beyond the abilities of the people who implement web forms.

jcrawfordor

a day ago

USPS doesn't care; each ZIP code has a single preferred city name and a list of acceptable alternate city names to account for cases in which a ZIP code spans multiple cities. However, USPS's address validation will prefer to use the preferred city name for the ZIP regardless of whether the recipient actually lives within the boundaries of that city. That's because USPS has opted to organize addressing entirely around the ZIP codes, and other political boundaries are irrelevant except in cases of problems interpreting the address.

This does mean that you might autofill a city name that is "wrong" in the view of the person completing the address form, but much of the bulk mail they receive probably uses that city name anyway.

Technically speaking ZIP codes are not "supposed" to span states but, in exceptional cases, some do. In this case USPS handles it the same way: the state of the preferred city is the preferred state for the ZIP code.

The preferred city is almost always the location of the post office serving the ZIP, which makes this situation fairly intuitive. You can find some interesting edge cases where a post office in located in a suburb city, resulting in a ZIP that includes part of a major city having the suburb as its preferred city name.

You can look up the city name and alternates for a ZIP here: https://tools.usps.com/zip-code-lookup.htm?citybyzipcode and the Domestic Mailing Manual covers this, although it's scattered across several sections and mostly part of how the City State database (the database used for validating city and state names in addresses) works.

I agree using the preferred city name works just fine for USPS, though maybe not for UPS/Fedex.

What I want to know is: Why isn't this preferred city+state mapping dataset for zip codes publicly available from USPS? It would be like 40kb of data for the entire thing. Why is this not public domain from the US Government?

Edit: or is this what I'm looking for (the "Physical City", "Physical State" columns? https://postalpro.usps.com/ZIP_Locale_Detail

It's missing 00501 at least (which zippopotam has), and military zip codes (which zippopotam doesn't have). Military zip codes are included in this file: https://postalpro.usps.com/areadist_ZIP5

Also fun fact 88888 is for "Operation Santa" uspsoperationsanta.com, which zippopotam is missing, but appears in the areadist_ZIP5 file.

jcrawfordor

2 hours ago

Unfortunately these USPS datasets are not public because USPS sells them. Or in some cases, the pattern tends to be that USPS has a contract with a provider (part of what I call the Postal Industrial Complex) that maintains the database and then sells it to both USPS and everyone else. Since these databases are used primarily by bulk mail services, they're fairly expensive and represent an important revenue source to USPS. Remember that USPS is semi-privatized, so they're looking for fees they can charge like everyone else... especially fees that can be changed more easily than postage rates.

That said, the ZIP DB is indeed not very large, so you can find copies of it. You won't generally find complete copies of the City State file but I wouldn't be surprised if there is one out there.

dataflow

a day ago

> Technically speaking ZIP codes are not "supposed" to span states but, in exceptional cases, some do. In this case USPS handles it the same way: the state of the preferred city is the preferred state for the ZIP code.

I've heard this before but it raises a million questions for me and I don't understand how this doesn't cause massive systematic problems and headaches in practice. Are residents even usually well-aware what city they live in, versus what's on their postal address? I sure as heck have always assumed whatever my mailing address says is the city I live in; I can't imagine a ton of people questioning it.

Doesn't this mean a ton of citizens would be registering for the wrong state's elections? Do the election officials always catch these? What about businesses - don't they constantly pay taxes incorrectly if the address is written incorrectly? What about laws (say privacy, wiretapping/call recording, etc.) where people make assumptions based on the city and state - what if they're wrong because the written city isn't the actual city? Who's criminally liable then?? Does every business have to perform a jurisdiction lookup to make sure an address isn't misleading?

jasomill

a day ago

My dad had an address in Morgantown, Indiana, and the fact that he lived several miles south, over the county line and past antother small town, always made it pretty clear to me that he didn't live in Morgantown.

Likewise, if you live in another state, there's little confusion because state lines appear on maps and are well marked on all major roads.

Businesses and individuals are responsible for knowing which state they reside in and paying the appropriate taxes, regardless of where their mail is sorted.

As for elections, electoral districts don't generally align with city limits in the first place, so this has to be sorted out by the election registration system based on the full address in most cases anyway.

As for what city name appears in legal documents, the answer is that "preferred" doesn't mean "mandatory". A warrant to search the Indianapolis Motor Speedway, 4790 W 16th St, Speedway IN, 46222, would be perfectly valid, despite the fact that the USPS prefers mail to be addressed to "Indianapolis" rather than "Speedway". For there to be any possibility of confusion, you'd need to have two distinct locations, whose identical addresses share a ZIP code, and differ only by city name, which for obvious reasons the postal service will not allow.

dataflow

6 hours ago

Thanks for explaining! That's a great perspective/experience that helps me understand it better.

Re: legal documents: there are less severe cases than warrants that I would expect to trip a lot of people up, which is what I'm wondering more about. Example:

ZIP code 97635 is apparently in both Oregon and California. The post office for both sides of the border appears to be in New Pine Creek, OR 97635. So if someone provides you with that address, you would quite naturally assume they're in Oregon. And you might collect taxes, record calls, or sell their personal data based on that. But whoops! Turns out they're actually in California, so you just broke a bunch of privacy laws on top of missing tax payments to California, in some cases potentially risking criminal penalties.

Wouldn't this trip a lot of people up, especially for smaller entities? I can understand multi-billion-dollar businesses having this all handled correctly, but for individuals or smaller businesses, wouldn't it completely throw them off and potentially subject them to criminal penalties? (How) would people deal with this?

jcrawfordor

2 hours ago

First, you're responsible for knowing where you live. Historically, people who lived in more challenging areas geographically often did not have regular postal addresses at all. You would just have a box number in the nearest town or a rural route stop number, and these obviously didn't reflect the legalities of where you lived. In our modern world, USPS has adopted a policy of 100% physical addressing, meaning that all properties now have a "real" address even if the number part is scaled from mileposts (as is the case in rural areas). Still, I think people who live in areas where any of this is less than obvious understand the nuance that how USPS handles addresses is not necessarily the same as how the voter registration clerk handles them.

Still, it is rarely a problem in practice, because anyone relying on addresses to establish these legal details will have to look at where the address is actually located---not just the city written in it. Keep in mind that quite a few people live in ZIPs where they could write multiple city names in their address.

When it comes to the unusual case of spanning states, it might help to note that the City State Database the postal service uses to validate addresses does not actually differentiate between city and state. "NEW YORK NY" is a single string. The state is really just part of the city name. The fact that USPS implemented it this way indicates the extent to which it does not matter in operational reality.

A sibling comment points this out, but it might also help to explain that in the US, it is very common for people to have mailing addresses in cities they do not actually live in. That's because of suburbs. City lines are often surprisingly arbitrary and reflect complex political histories. Many people consider themselves to live in [major city] but, in legal actuality, live in [unincorporated county that contains major city]. Many of the upsides of living in the city, sans some of the property taxes and voting in city elections! Yet another reason that people understand that mailing addresses are not definitive reflections of political boundaries.

If you ever work as an election clerk you will find this a LOT---people indignant that they cannot vote for the mayor, to whom you will have to explain, somehow for the first time, that they do not actually live in city limits. This tends to be more obvious if you get a property tax bill but a lot of people are renters and never really think about that aspect.

thfuran

a day ago

But addresses aren’t just for sending mail. Location also determines which municipal and state laws apply, so there are contexts where the distinction matters.

daft_pink

a day ago

I would just like to point out that the city field doesn’t necessarily prove anything because many unincorporated areas have a listed a city but may not be subject to the laws or taxes of a municipality. So having the correct city isn’t as useful as one thinks it is.

cvoss

a day ago

I used to live in just such a place. Went to the city center to apply for a library card, thinking "of course I can get a card here, I live in Foo City and this is the Foo City Public Library." I was asked for my street address, and she pulled out a binder of street names to check (yes it was analog, in the year 2016 A.D.). I was not within the city limits and was denied a card.

lacunary

a day ago

same thing happened to me last year, except at a brush drop-off rather than a library; analog binder and all!

aidenn0

a day ago

I live in a zip code that spans two cities and I live in the unincorporated area between them, but with one of the cities in my preferred address. So at least two of the exceptions listed in this thread apply.

Jimmc414

a day ago

This is accurate. For a scenario with a possibility of litigation you must ultimately geocode the address with google maps API or census geocoder, point in polygon against district boundaries (geopandas or shapely), then pass the result through a rules table keyed on jurisdiction + case type.

twodave

a day ago

It’s more that the municipal “geofence” encompasses a certain area, and all addresses that fall within that space belong to that municipality. I.e. the address doesn’t determine the location, it just happens to be located somewhere.

jagged-chisel

a day ago

These things shouldn’t be based on the zip code.

bicx

a day ago

This 1000 times. I’ve tried implementing what OP has mentioned, and quickly learned it isn’t possible. A city can also exist in multiple zip codes. And there can be multiple cities with the same name in the same state. So, to be safe, you have to enter city, state, and zip.

hyperbovine

a day ago

I don’t understand either of these arguments. They both appear to reinforce the point made in the article. At worst a zip code contains multiple cities? Voila the city box becomes a dropdown. It’s 2025. JavaScript.

adeon

a day ago

I get the vibe that it's more like there's unexpected complexity and it's difficult to be confident you know how zipcodes work with enough detail to make the feature work. And that is just one example of possible complexity.

Do zipcodes change for example? Can your drop-down quickly go out-of-date? You'd need a way to manually enter a city so people are able to tell the system an address. Do you want to bother making an auto-updating zipcode feature just for a form?

Is it going to confuse people because nobody else has bothered to make this superfancy selection feature thing?

Is this USA only? There are postal codes/zipcode-equivalents in other countries.

It starts to feel it's likely not worth the time and effort to try to be smart about this particular feature. At least not if I'm imagining this us some generic, universal address web form that is supposed to be usable for USA-sized areas.

To me it feels similar to that famous article about what you can and cannot assume about people's names; turns out they can be way more complicated and weird than one might assume.

Although maybe zipcodes don't really go that deep in complexity. But on the spot I would not dare to assume they are.

8n4vidtmkvmk

19 hours ago

Absolutely its worth the time to get it right.

What kind of app are you building? Maybe you're selling something. You probably want users to get through your check out form as fast as possible before they change their mind or get distracted or frustrated.

Or you're building an app for data entry and people are filling in lots of addresses every day. They would appreciate you saving them time.

Either way, spending a day or two to polish up your form can be worth a lot.

Not saying its trivial to get all the edge cases right, but I'm pretty sure we can do better here.

awesome_dude

a day ago

> Is this USA only? There are postal codes/zipcode-equivalents in other countries.

This is where the real problems start - postcodes exist the world over.

Speaking as someone that has dealt with countries that have postcodes, but no states, so it's just Street Address (if applicable) | City (if applicable) | Country | Postcode

Inputting a "zip code" first would result in every country being in the drop down.

In Australia, addresses too are wild, they should be considered "free form"

https://blog.melissa.com/en-au/global-intelligence/australia...

Gives this as an example address The Smith Family

'Willow Creek' Station

via Winton

QLD 4730

grahamburger

a day ago

I just placed a delivery order from home depot and this is exactly how they handled it. I put in my zip, they gave me a drop down of the cities that zip covers (there are like 5 of them, incredibly) and I was on my way.

singpolyma3

a day ago

Indeed. I don't always even do the drop down just make it autofill a still editable text box

devman0

a day ago

Even if a zip code contains multiple cities, each ZIP has one "preferred" locality name and you can default to that. Any of the locality names within a zip code is deliverable for all addresses in that zip code.

As has been pointed out in many other comments implicitly and explicitly, the purpose of a set of address fields in an HTML form is not always to come up with a USPS delivery address.

DangitBobby

a day ago

Does that mean you shouldn't choose sane defaults or...?

Many other comments here have outlined the problems with what TFA appears to consider "sane defaults".

But sure, if you can do it right (e.g. "Put the country first"), then by all means do so!

As long it does become a dropdown, fine.

But in TFA's example it does not (my zip has 3 possible city names; TFA's example shows only 1).

aidenn0

a day ago

Except that's not what this page does, so it's harder than TFA makes it out to be. I am in a zip code that spans two cities, and it won't let me change the city name at all once I put my zip code in.

ghostly_s

a day ago

> A city can also exist in multiple zip codes. And there can be multiple cities with the same name in the same state.

These are reasons you cannot deduce the Zip from the city, not the opposite. A ZIP+4 actually encodes all other information for a US address.

Someone1234

a day ago

Nobody knows their +4 code. You cannot ask for information 90%+ of people won't have.

fingerlocks

a day ago

If asking for the zip first was more common then we quickly learn those four extra digits because the auto fill benefits would be immediately obvious

awesome_dude

a day ago

Why?

I have a 4 digit postcode, I have to look it up every time I have to fill in an address form for delivery.

I've had people screw 1 digit up in that postcode and their items (a laptop in one case) went to the completely wrong city.

A code sounds foolproof, until you realise most people don't engage with them for most of their lives - you don't tell the uber driver the zip/post code you are waiting in, and travelling to, nobody does.

edit: just to add - Magic numbers are bad. Software engineers know that a number that's undocumented in code is unmaintainable, a zip code is worse.

Dylan16807

a day ago

> I have a 4 digit postcode, I have to look it up every time I have to fill in an address form for delivery.

> A code sounds foolproof, until you realise most people don't engage with them for most of their lives - you don't tell the uber driver the zip/post code you are waiting in, and travelling to, nobody does.

When the above comments said +4, they meant knowing the second half of the nine digit zip code.

Basically everyone in the US knows the first 5 digits. It's really easy to memorize them. If you can remember your city, you can remember your zip code. And in the US you use it all the time, so it stays memorized.

> edit: just to add - Magic numbers are bad. Software engineers know that a number that's undocumented in code is unmaintainable, a zip code is worse.

That complaint about magic numbers is completely off base. Magic strings are just as bad in software. "Beverly Hills" and 90210 are equal sins on the magic front.

awesome_dude

a day ago

> Basically everyone in the US knows the first 5 digits. It's really easy to memorize them. If you can remember your city, you can remember your zip code. And in the US you use it all the time, so it stays memorized.

What's the 5 digits for Yonkers New York (edited because I originally had NYC)

> That complaint about magic numbers is completely off base. Magic strings are just as bad in software. "Beverly Hills" and 90210 are equal sins on the magic front.

For the same reasons, that's why it would be: Beverly Hills, Los Angelos County, California, USA, 90210

Dylan16807

21 hours ago

> What's the 5 digits for Yonkers New York (edited because I originally had NYC)

Nobody sends packages where the destination is an entire city. If someone gives me an address inside Yonkers, it'll have the zip code in the address. I've never had to look up a zip code in my life.

> For the same reasons, that's why it would be: Beverly Hills, Los Angelos County, California, USA, 90210

Which reasons? That has nothing to do with magic numbers, except that a 'magic full mailing address' is still bad, you don't shove that into the middle of your code either. If you're looking at the "made a typo" reason then that's where showing the address after putting in the zip code will give you the same verification but faster.

awesome_dude

20 hours ago

Heh, you should take a minute to look the answer up -

ZIP Codes 10701, 10702 (post office), 10703–10705, 10707 (shared with Tuckahoe, NY), 10708 (shared with Bronxville, NY), 10710, 10583 (shared with Scarsdale, NY)

Dylan16807

18 hours ago

Is that information supposed to change my mind about something?

If you put in any of those numbers it can prefill the city name, with enough accuracy that you don't need to change it.

Did I imply anywhere that cities only have one zip code before you asked about Yonkers? I said if you can remember your city name you can remember your zip code. That doesn't imply you would use a list to get from one to the other.

awesome_dude

8 hours ago

It would have improved your response was all - nobody accused you of anything, but this response of yours... way off

Dylan16807

8 hours ago

Improved how?

I picked up the implication that you thought my response could be improved, so I tried to guess what your criticism was and respond to that. If it feels "way off" because I framed it as disagreement, then I dunno, that feels like the right framing? Unless it's something else I did? I could have made it clearer I was guessing but that doesn't seem way off.

bluGill

a day ago

Your zip plus 4 changes. It isn't worth trying to know as it isn't supposed to be constlnt. If you send a lot of mail there is a discount for using it but you have to update everyone's address often (iirt at least 4x per year)

fingerlocks

18 hours ago

Source? The numbers correspond to the USPS distribution centers and carrier routes. If the numbers are changing that would imply an increase in zip code subdivisions, making each zip code a better address predictor for a given individual.

Of course they do.

Let me uh just grab my utility bill...

10% of the US population is 35 million people. That's a pretty weird version of "nobody".

collingreen

a day ago

This is a bad hill to die on for a ux conversation. "10% can feel kind a big number when 100% is huge" is a funny argument, as is trying to be pedantic about "nobody knows" as a shortcut for "most people won't know and you can't rely on any particular user knowing". If 10% is big enough to matter I can't wait to tell you about 90%!

I'm not suggesting that one would design for the 10%, but I also think that writing off 10% - "nobody" - (particularly of a large number of people) is pretty dumb too.

albedoa

a day ago

> "10% can feel kind a big number when 100% is huge" is a funny argument

That would be a funny argument if it were the one being made.

bombcar

a day ago

A ZIP+4 does not encode all information.

Proof: a post office has its own zip code, for PO Boxes.

The +4 is the last four digits of the post office box.

If the Post Office has more than 10,000 boxes, the +4 will be duplicated.

twodave

a day ago

Yeah, anyone who has had to work with USPS bar codes should know that internally these are called routing codes, and they come in 5, 9 and even 11 digit variants. The 11-digit one narrows down to a specific delivery point, but even that isn’t enough to derive an address (just enough to know whether you’re looking at the right one or not). Zip+4 codes also change frequently because they aren’t based on locations but on delivery routes and sequencing.

fn-mote

a day ago

> Zip+4 codes also change frequently because they aren’t based on locations but on delivery routes and sequencing.

This was news for me. I know the few zip+4 I memorize never change.

I think the source for the parent is AI slop. See [1].

> Due to an increase in population or to the improve postal operations, the US Postal Service® will occasionally add a new ZIP Code or change ZIP Code boundaries.

The plus four digits encode:

> [67] : Sector or Several Blocks

> [89] : Segment or One Side of a Street

Note that this contradicts the parent.

[1]: https://faq.usps.com/s/article/ZIP-Code-The-Basics

twodave

a day ago

The census bureau (very) periodically publishes zip code data (which is where some places get their geolocation info). If you work with enough addresses you’ll find some zip+4s that are wildly far away from where they used to be. There are paid services that have better accuracy, but I’m not sure how they acquire their data.

bombcar

a day ago

Some people don't realize just how much you can "customize" deliverability with the post office, especially if you're big (like a school or large business) - you can have something that looks like your physical address, but is actually really a maildrop/PO Box at the nearby post office.

You can do relatively complex forwarding that would only appear to the end users if they can decode the barcode.

Twey

a day ago

ZIP+4? I think that's literally enough digits to give every house in the US (about 150,000,000 apparently) its own identifier.

collingreen

a day ago

Zip isn't uniformly distributed numbers though so you dont have the equivalent of that many digits of decimal numbers. Other comments have more detail but just for the top level example the first number is the zone and goes from 0 on the east coast to 9 on the west.

bombcar

a day ago

Only if there's never more than 10,000 addresses in a single zip code, which means that if you enforce that, you can force a zip code to appear by building enough house

Twey

10 hours ago

I think my point is that if you're going to make people learn a 9-digit identifier for their house you might as well make that identifier unique and then that's the only information they need to fill in. Having non-unique 9-digit identifiers feels wasteful.

axiolite

a day ago

That happens, and worse. I've lived in multiple areas that have had their zip code changed. Area codes, too, sometime more than once.

kube-system

a day ago

There are far more addresses than there are houses

Wrong. There can also be multiple cities in the same ZIP code. There is not a 1:1 relationship with a 5-digit ZIP as everyone is assuming here.

axiolite

a day ago

I've implemented it, too, and didn't run into any problems. User inputs the zip code, if there's multiple city matches, they select the correct one from the drop-down (or you auto-complete the city name after they type the first 4 letters).

The fact that "A city can also exist in multiple zip codes. And there can be multiple cities with the same name in the same state" is a good point IN FAVOR of asking for the zip code first (NOT to avoid it) because you certainly can't do it the other way round.

And if you just leave it to the user to free-type all that info in, you have to verify it after... Users are going to make typos, and the USPS will kick your butt if you don't correct it (and credit card payments won't go through, either). So it may be less work for web-form creators, but pushing the verification down stream just makes it all worse for the company using it.

wooptoo

a day ago

The postcode doesn't tell the whole story. But what you can do is use an IP geolocation service which should narrow down your location enough, so that typing in the entire address is no longer necessary.

I.e. using something like https://ipinfo.io/json and then typing in a full postcode and street name + number should work well in most cases.

twodave

a day ago

IP geolocation is increasingly not useful for anything, especially for mobile users. The best it can do is give you the correct country and maybe get you in the right region.

8n4vidtmkvmk

19 hours ago

That link nailed me perfectly. I'm on my phone. Connected to wifi, like most people probably are. Chilling in bed or on the toilet.

If you're on cell service.. yeah probably less accurate. Not sure if it makes the form harder to fill out if you have to change some of the fields.

What I've started doing for my personal app though is I've added a "guess" button. It fills in the form using heuristics but it's opt in. Fills out like 10 fields automatically and I've tuned it so it's usually right, and when it isn't correcting a few is still quicker.

hluska

a day ago

What if I order something on the road and want it delivered to my home? Or what if I want to order something over mobile? My mobile IP is often 1500km away from where I live.

Autofill solves all of that with an implementation cost that approaches zero.

tomjakubowski

a day ago

There are enough ZIP+4 codes for about a billion addresses. Many addresses I've lived at in the US have had a unique ZIP+4 code.

kube-system

a day ago

The digits aren’t random though, some of them have meaning.

ptdorf

a day ago

> A city can also exist in multiple zip codes.

Sure but a zip code belongs to only one city and one state, right?

8n4vidtmkvmk

19 hours ago

No... That was addressed elsewhere. That's the bigger problem

bell-cot

a day ago

Make that 1003+ times. At least in my part of the US, even a pretty modest-size city will have multiple zip codes. And zip codes can have zero geographical footprint (meaning street address) - for example, some zip's are just for Post Office Boxes. And a physical address can have an official USPS address & zip of "Middle City", while physically being in (say) Middle Township. And other fun stuff.

gruez

a day ago

>Make that 1003+ times. At least in my part of the US, even a pretty modest-size city will have multiple zip codes.

Is that an issue? Who cares that new york city has 20+ zip codes? Just fill autofill "new york city, new york".

>for example, some zip's are just for Post Office Boxes.

Again, is it bad except for some joker who wants something sent to an invalid address?

> Instead, learn to use your browser's autofill feature, and design your sites with it in mind. If you do it right the user literally doesn't have to type a single character.

Funny that the best solution is circa-1997 Netscape 2.0-level technology, while everyone iterates on how we can make everyone's life worse with even more unnecessary JavaScript. Like we all collectively forgot what the <FORM> tag does.

To type an address on a letter, something a 5 year-old could do with a crayon.

Address forms, with unnecessary and unhelpful drop-downs, many of which reject keyboard input and require use of a mouse to scroll through them, are the bane of my existence.

karmakaze

a day ago

These details don't detract from the efficiency. The postal code can prefilter every other field which can frequently narrow down to one. I would leave the ability for the user to override with free form data entry as data isn't perfect and changes over time.

I don't remember asking for "efficiency" in typing out an address, something we teach children how to do. It doesn't seem like a societal problem worth iterating over.

These tools are more than often wrong, and cause more grief for the user than any potential help it could provide.

There is no developer in the world that knows this data better than the person typing it into the form.

karmakaze

a day ago

I'd like any person or system asking for my information one field at a time to minimize my time and effort to give it to them.

When they make erroneous assumptions, which they often do, they steal more of your time and effort than it would take without "assistance".

I bet a large majority of Americans have their city and state uniquely identified by their zip code

if it's not unique, a trivial fallback would be to not populate anything, and that's where we are today

Someone1234

a day ago

The linked article feels like it is going to get linked in a response article titled "Things you don't know about zip codes" in the next 48-hours to a week.

spagettnet

a day ago

If something is more efficient 95% of the time, and as efficient as normal for the rest of the time, its still a good solution.

kabamo

a day ago

if there are multiple cities, then just don't auto fill

that way it's faster and easier for 90% (just a guess) and no different for folks that have multiple cities on that zip

angra_mainyu

5 hours ago

To this, I once moved to a city in a neighboring country and ended up having the exact same zip code as where I moved from.

Or if theres a collision dont autofill it. The rest of us will be glad you autofill for us.

Groxx

a day ago

yeah - I do think zip first to bring matching things to the top of your other dropdowns and lookup results (not filter, just prioritize) is almost certainly a good idea, but it's very much not an always-match.

trick-or-treat

19 hours ago

Zip codes aren't numeric. They're strings. Just came to say this because I've been on 20+ projects that treated zip codes as numeric and had to reckon with it later.

nine_k

a day ago

This is true, but in like 95% of cases, the ZIP code determines the state and the city (and the county, when it matters). Pre-populating them would save time to a lot of people.

Those few with the luck to live at zip codes that span cities and cross state borders would still still have to fill these in manually, like the 100% of us currently.

It's a pure improvement with no downsides, except the downside of slightly changing the 100-years-old sequence of address fields. Put the ZIP code first, and your customers are going to be happy with that.

detourdog

a day ago

I'm always struck at how the state abbreviations are alphabetical order of state name. This leads to the abbreviation not being in strict alphabetical order.

idlerig

a day ago

This. I have to fill out a form that requires uses the ZIP code to look up cit(ies) and state, but often has multiple options for county, which I have to look up in a separate tab independently. It's not the huge time saver it should be... unless we start including ZIP+4, but I couldn't even tell you my own address with +4.

zwily

a day ago

I'd be fine if it autofilled one city from the zip code, which for me is always wrong. I can tab to the field and type in the correct city. Don't even need a drop-down with the possible cities. And if I don't fix it, it doesn't really matter for USPS. They just care that the ZIP is correct.

brikym

a day ago

So it's another "Falsehoods developers believe..."

US-centric. I typed a Mexico postal code (it’s five digits) and got routed to somewhere in Maine. So - yeah the whole “I can tell you’re in the US just by the zip code” premise is entirely flawed.

birdsongs

a day ago

The best times are when US ecommerce sites try to confidently lint foreign addresses, even when they allow shipping there.

I've had them tell me I need 5 digits for my postal code in Norway, which uses 4 digits. I selected Norway in the shipping web form.

Or when they tell me special characters aren't allowed, yet the "special characters" are just letters in the Norwegian alphabet. My address contains ø. These aren't even unicode, they're in the extended 8 bit ascii set. Why are you linting these!?

These happen all the time. Thankfully our postal system recognises this and allows some substitutions (å=aa, ø=oe, æ=ae).

Macha

a day ago

I remember US based sites insisting I provide them a post code for like a decade before most of my country _had_ post codes.

birdsongs

a day ago

Hah. Post codes are just weird and non standard. I've had times travelling where the point of sale asks me for a zip code after using my non-US card.

I learned from a cashier to type 00000 and it has always worked.

Ekaros

8 hours ago

Or some strange concept of state. Well there is some upper divisions, but postal service does absolutely nothing with them and they are never part of any address.

avidiax

a day ago

Should be titled "Put the Zipcode and country first".

Would be simple enough to have someone type the zip or postal code first, then move the countries that are known to have that zip code to the top of the drop down (still in alphabetical order), and all the other countries below that (also in alphabetical order).

Leave all the fields editable, i.e. the postal code only suggests, ranks, or prepopulates.

Seems like that would handle all the edge cases, including those where a zip code doesn't refer to one and only one city, or where a zip code has changed or been added to a country.

notpushkin

a day ago

Yeah. But also, are you ready to maintain a postcode to city mapping for every country you have a significant userbase in?

avidiax

19 hours ago

I'm definitely not, but the lazy method is just to cache the data your customers provide, or curate some data for the countries you are most interested in.

That gets around countries that consider their postal code database a licensed dataset.

peyton

a day ago

ZIP Code (tm) is claimed as a trademark by the US Postal Service. If you don’t have a ZIP Code, why would you put something in the ZIP Code field?

rmunn

a day ago

Because most websites won't have two separate fields for "ZIP code" and "postal code". Even if they knew that ZIP Code is a trademark (I didn't until you mentioned it), they would (wisely) know that putting in two fields would just confuse most people. So they put in one field. Many sites label it as "ZIP code / postal code", but some just label it as "ZIP code". But the intent is clear: put in the multi-digit string that identifies your address, whether your country calls it a ZIP code or a postal code.

pstuart

a day ago

Put a postal code first.

Include a field for the country that is autofilled via Geolocation API or geoip if that's unavailable.

notpushkin

a day ago

Put country first. Postcode doesn’t make sense without one. Prepopulating one based on location is generally okay, but don’t assume it will always be the same.

Or just don’t try to be too clever.

NicuCalcea

a day ago

Yup, the second sentence in the post is incorrect.

> From those 5 characters you can determine the city, the state, and the country.

You can't infer the country from a postcode.

hyperhello

a day ago

In the example, you might at least be able to cut down your menu choices to Maine or Mexico.

NicuCalcea

a day ago

That assumes the existence of a reliable, free postcode API of all addresses on the planet.

I did a very brief search, and none of the commercial offerings I could test recognised the postcode of the Eastern European neighbourhood I was born in. Also, like half of African countries don't have postcodes. It's just not a good system.

gmueckl

a day ago

Only if you're limiting yourself tok those two countries. A lot of countries use the entirety of a 4 or 5 digit range for their codes. Any given 5 digit number is likely a valid ZIP code in at least half dozen countries.

II2II

a day ago

The form stopped accepting input at five characters. I could not enter a "zip code" for my country even if I wanted to.

Even if they fixed that, there are other issues. (You pretty much need to cross-reference it with a database, which assumes said database even exists.)

thrance

17 hours ago

France also uses 5-digits zip codes, and many other countries too I'd wager.

mrb

a day ago

Yup. I typed my French ZIP code (code postal) and this guessed a US city...

But the author has a point. Combine it with some approximate country-level geolocate of the web client and this would work perfectly 99% of the time modulo edge cases like VPN users.

II2II

a day ago

In the mid-1990's, I requested information from a major multinational corporation (IBM) that had a significant presence in my country. They somehow managed to mangle the six characters of a Canadian postal code, which alternates between letters and digits, into a five digit zip code. Making it even more perplexing, the envelope was addressed by hand and came from New York state. Some Americans seem to think that the rest of the world is a mirror of them, and will go through unusual contortions to maintain that belief. (To be fair: there is another level above that which is Anglo-centric, which allows for just enough variation between English speaking nations.)

I have seen websites that more-or-less takes the author's advice though. They are country specific. They are backed by the postal system's database. They present a list of addresses that match up with the postal code. They do not work very well when a particular address does not have a postal code. And yes, that happens.

Yeah, post codes are a huge pit of an implementation. Each country has their own way of presenting and formatting them, as well as additional validation rules (e.g. valid postal districts). This should be amazing (and is), but if you maintain such a validator you'll have a continuous stream of bugs where clients were able to make a mistake they shouldn't have been able to (often breaking downstream where it is hard to recover) or where you refuse to accept somebodies very real address and they are very personally upset (rightly so).

That said, the obvious solution is <country> <post code> where <country> is prepopulated from geo-ip or browser signals or similar.

jsLavaGoat

21 hours ago

Yes, it is US-centric. You all act like that many commercial websites are just like automatically doing international business. I am not even allowed to do business out of my state. I don't even need that filled in. You can see my website anywhere, but you can't be my client unless you're in my state. So I don't care.

Any company able to do business in multiple jurisdictions, well, that's just the kind of extra thing they can handle.

For an enormous amount of sites and for an enormous amount of users this is an improvement and the general reaction here is nitpicking and this self-evident charge that it's US-centric. So what. The principle would apply in most places.

In Costa Rica, there are no addresses but there are (now) post codes. You would have to take that into account to do business there. If this doesn't apply to you then it doesn't apply to you.

It's not like the internal US market is small. This solves a problem for a lot of people in a lot of cases.

aunderscored

21 hours ago

The problem is this reduces usability for others. Yes, there are many local to a country sites, but there are also large scale global ones. In both cases, you're not really gaining anything other than some clever autocomplete that could be far more precise if the site offered the correct fields so that whatever autocomplete tooling I use can put the data in for me.

The page itself specifically says "and country", however that too doesn't work. Other non us countries may have the same postal codes, or in my case mine is 4 digits, and I had to figure out that "oh, this is us only and it doesn't work at all for me", which was just entirely a waste of time.

its-summertime

20 hours ago

From the site: "scroll through 200+ countries to find United States" is talking about an international form

8n4vidtmkvmk

19 hours ago

I can live with lack of auto complete if i don't live in the blessed country. What's bad is when it rejects a perfectly valid address.

E.g. trying to enter a Canadian postal code in a US zip code field fucks a lot of things up. Very frustrating for Canadians trying to buy gas in Washington when the pump asks for a zip.

Spooky23

a day ago

The UI pattern is still stupid. You should be able to quickly enter forms like this on a keyboard.

When I look for a part for my car, I pick “Honda”, “Model Year”, “model”, “trim”.

With address forms, if I type “U” in a keyboard aware field, it defaults to “US Minor Outlying Islands”. Places that try to accommodate will put the US and Canada first.

If you asked country, first, you could utilize the postcode method. Some sites try to autocomplete street address which I personally find annoying as my street is a common streetname.

fy20

a day ago

Being from the England is even worse, 'Country' could be any of the following:

United Kingdom

Great Britain

Britain

England

ndsipa_pomu

17 hours ago

Meanwhile, here in Bristol, a whole bunch of sites insist on using a drop down for the county and list "Avon" which doesn't even exist. It should be Bristol or possibly City of Bristol.

johneth

16 hours ago

I think the county list is set in stone because Royal Mail refuses to update them (for some idiotic reason they still control the postcode database, which I guess lots of websites use and therefore use the old county names / boundaries). For example, it's still Humberside, even though that hasn't existed for decades.

ndsipa_pomu

3 hours ago

Yep, I recall that Royal Mail is one of the websites that has the "Avon" issue. I don't know why they don't just update it to make it accurate as they update their PAF files for postcode lookups every three months with new postcodes. "Avon" is strange as it's still used in some contexts, such as the police force is known as Avon & Somerset

idlerig

a day ago

Small distraction, entering the year first is preferred for vehicles, as manufacturers changed names (Nissan/Datsun) or were discontinued (Saturn, Pontiac) after known years.

wildzzz

a day ago

A tangent, but I've always wondered what is the most efficient way to order the drop-down menus for year, make and model. Assuming your a retailer for hard to find car parts, e.g. rockauto, how do you order those menus such that someone has to do the least amount of scrolling? Year cuts down a number of defunct or newer manufacturers but Make cuts down the number of years for that same group.

hakfoo

a day ago

I went year-make-model many years ago when I did an autoglass website.

The filtering value is big as you said, and the model year as a first filter is easy to type in, and probably gets you reasonably close if you're off-by-one. Accidentally picking an '05 Sonata instead of an '04 probably has similar parts, but if you pick Honda instead of Hyundai, you're way off in Wonderland.

mcfedr

21 hours ago

the first words on the site - this is for American sites...

stavros

a day ago

So I typed my zip code and got Winsconsin, and couldn't change the country to Greece, which is what my zip code actually is for.

Proposing UX improvements is great, but please don't forget the other 95% of the planet.

yardstick

a day ago

Agreed. I suppose they could lookup based on your IP to pre-select a country (which you can still override if you need to aka VPNs and ordering from a different country), and based on that then ask for a postcode.

8n4vidtmkvmk

19 hours ago

I thought your 95% was off but 300 mil/8000 mil is about 4% population for US!

sph

a day ago

Falsehoods US programmers believe about addresses: there are no other countries than the US of A, and if there are, they don’t really matter.

This person bought a whole domain for something that doesn’t work for 90% of the world, claiming it does, never even testing their assumption. Great job!

digitalPhonix

18 hours ago

> Fine, maybe country first. The purists in the comments are technically correct — postal codes aren't globally unique. You could do country first (pre-filled via IP), then postal code, then let the magic happen. The point was never "skip the country field." The point is: stop making me type things you already know.

It’s addressed in the article (at the end, admittedly).

orphea

16 hours ago

Perhaps the author should make the country dropdown consist of just two items: "US" and "Purists in the comments".

_dain_

10 hours ago

The existence of countries other than the US is not a "technicality".

But it doesn't matter because the whole article is AI generated.

marcellus23

a day ago

I don't disagree with you generally but does he really claim it does? The entire page only mentions US, near as I can tell.

sph

a day ago

> From those 5 characters you can determine the city, the state, and the country

And the country field is completely useless as you can’t change from USA.

krater23

a day ago

He just doesn't understood that every country has his own zip codes. He just comes from the land of the free invention of units of measurement ;)

sagacity

19 hours ago

Actually, visiting from The Netherlands showed me a popup congratulating me on the quality of our postal code system.

fellowniusmonk

21 hours ago

Yeah, this is 100% an instant classic in the lies programmers believe series.

How long have we had browser auto complete for addresses? A long time, I assume it's devs like this one who just can't be bothered to support it and have to pretend their flawed approach is somehow faster than literal auto complete.

1970-01-01

a day ago

The name and shame tactic is underrated these days. :)

zettabomb

a day ago

I fail to see how you can claim this to work for sites which serve areas outside the United States, but have either no ZIP code, an overlapping code, or something else entirely. Germany has 5 digit PLZs, but putting some valid ones in doesn't get a result. It really seems like the author does not think about other countries.

I don't disagree with reordering the entry by relevance, but you have to start with country. That can also be a nice search - it will be a very short lookup, even if you put every country name in every language. Only after that is postal code (of whatever kind - it's only ZIP in the US) relevant.

diath

a day ago

Ok but that only fetches the codes from the US, so now a non-US resident will start with their zip code and end up with random ass place on the other side of the globe. Now not only I still have to fill in the fields, but also clear them first.

jen20

a day ago

Obviously put country first, then whatever the equivalent of a ZIP code is second. In the UK, a post code gets you down to around 15-16 delivery addresses on average. No-one there really _ever_ needs to type an address.

NicuCalcea

a day ago

Most British websites work like this website suggests, in that they ask for the postcode first, then give you a dropdown of all the addresses at that postcode.

It works great, except my address is for some reason not in whatever databases these websites use. The building number is on the list, but not the individual flats. So I have to put in the postcode, choose something like "My address is not listed", then fill in the form manually. A few times it wasn't even offered as an option.

roryirvine

17 hours ago

Yeah, there are plenty of annoying edge cases.

For instance, my postcode covers 15 houses and half of a large park. Those houses have been subdivided into 4-6 flats, and many have been redivided or renumbered multiple times. The park also contains various buildings and other places that might plausibly receive deliveries, some of which have multiple entries (an electricity substation appears 8 times, for some reason). So in total, it covers more than 200 addresses - mine is no.140-ish in a typical sorted list.

You'd be amazed by how many address checkers can't handle more than 64, 100, or 128 addresses in a postcode. Or how many scrollbars stop working, requiring you to use the arrow keys to navigate. Or how many other glitches I've seen.

The other common problems are usually down to temporary postcodes (which used to always end with an 'X' but can now be indistinguishable from 'real' codes) escaping into the wild, re-addressings and re-numberings not being picked up properly, the old problem of outdated PAFs being used, and - my personal favourite - BT/Openreach using their own separate postcode database, dating from the Post Office split in the early 1980s, which doesn't always agree with the PAF. Agh!

tialaramex

19 hours ago

Somebody else mentioned the PAF. I should further clarify why your address might (might, this could just be a mistake) not be on there and why therefore almost any form should have an option to "do it the hard way"

The PAF is about what the Royal Mail calls "Delivery Points" which are places they promise to deliver physical letters to. Inside my building for example every home has a front door, with a letter box, and letters literally get posted into my flat, but down the street there's a building with a rack of boxes set into the wall and post is delivered to your numbered box, and up the street there's a townhouse converted and all the mail just goes in one piles for everybody in that building.

Many delivery points share a postcode, but because they know them all they actually all have unique numbers, and unlike a postcode they're not for humans so they get changed quite frequently as new buildings are constructed or working patterns change, if you examine your post carefully (in the UK†) there are two rows of fluorescent orange dots on the outside, these were printed by mail sorting machines shortly after the mail was received, one is an entirely arbitrary serial number and it designates that piece of mail for a very short period (say a few days) to enable statistical tracking for performance - if #213940202 entered the system in Glasgow on Monday, was in Portsmouth by Tuesday but wasn't delivered to someone's door until Friday the problem ain't in Glasgow. But the other one we're interested in here is the Delivery Point as a numeric code. If you don't have multiple addresses this row of orange dots will be identical on every item you've received for some time yet it's different on someone else's mail.

† This trick was invented in Britain but is used (licensed) in some other countries because it's a good idea, however exactly what is encoded and so what it "means" may vary.

“Obviously” didn’t read the article. Not having to pick the country is literally the premise!

“I type 90210. You now know I'm in Beverly Hills, California, United States. You didn't need me to tell you that. You didn't need a dropdown. You didn't need me to scroll past Turkmenistan.”

n0w

a day ago

The author seems to have either misunderstood the API they're referencing or are assuming US only addresses. The specific endpoint they're calling seems to be for US specific zip codes.

The point stands that this doesn't "just work" for global services.

scottlamb

a day ago

"Obviously" the article is wrong, as pointed out by the grandparent of your comment (and several others in the comments). I won't violate the site guidelines by suggesting you didn't read it.

I did read it.

scottlamb

a day ago

Great. Pretty sure jen20 did too; they are replying to a comment pointing out the article is wrong and suggesting a compromise between the web default "enter all your address, then the zipcode" and the article's "you don't ever need to touch the country, state, or city fields" that is closer to working beyond the US. In that context, I find it strange and rude that you're suggesting they didn't read the article.

You also suggested I hadn’t read it. “I won't violate the site guidelines by suggesting you didn't read it”. Only you did (saying you won’t say something and then saying it doesn’t really absolve you).

I find you rude so I won’t reply to you anymore.

Dylan16807

a day ago

They were pointing your own faulty claim back at you, in the hope that you would reconsider it.

You should not be treating it as a standalone accusation, and it's not justified for you to get mad at them without getting just as mad at yourself.

collabs

a day ago

At that point, should we even show the whole form? Or should we only ask the country first and then based on the answer, decide whether to show a form? That way the form can be different for each country?

I think auto full suggestion should be just that -- a suggestion, not validation.

Yeah, I’m thinking about how the address validation databases would for years correct my house’s address to point to a house in a cul-de-sac a block away. I could tell who was auto-correcting my address by which parcels arrived there. The USPS carrier knew too and he would ignore the address on some parcels.

I eventually had to dig through a bunch of USPS documentation for their Address Element Correction database to find their helpdesk. Apparently places like Fedex use that database.

So I agree as well, and I would be pretty angry if someone forced me to pick from a list instead of just trusting that I know my own address.

Also as another aside I was a shipping clerk for a while and occasionally came across an address like “across from such-and such store halfway down the alley.” So the author is making a pretty bold assumption that there is such a thing as a standard address that can be auto-filled.

zettabomb

a day ago

Yeah but, the article was specifically saying that you don't need to put in country because you can look it up by ZIP. That's obviously wrong, but apparently not to the author of the website.

lsaferite

a day ago

Even in the US, once you have a zip and a name the post office can often deliver mislabeled mail. Results my vary by region though.

hirvi74

a day ago

I have a better idea. How about we just let the users input their own addresses? These days, most browsers autofill addresses anyway.

iberator

a day ago

I don't own a post code and permanent residence. It's a pain in the ass to find some local post code whole in rush etc silly idea

zackwu

an hour ago

As pointed out by many comments, the post seems US-centric and using zip code doesn't work for all countries.

But just for reference, in Singapore, we use 6-digit zip codes, each of which can uniquely locate a single building, so yes, a lot of local websites essentially just expect a zip code plus unit number, without the hassle of typing out the address at all.

Maybe what I wanted to say is, the idea is cool and _can_ work to enhance user experience with proper localization.

mikehall314

a day ago

It’s easy enough to say “put the zip first because that will tell you city, state and country in one input”.

What happens to customers not in the United States? They have no zip to enter. Or if they have a postal code of some stripe, it has a different format.

What about folks who are in Turkmenistan, that you’re grumpy about having to scroll past? How are they signing up?

acidburnNSA

a day ago

I think they can just skip the zip code entry and enter everything else as usual.

kawsper

a day ago

A lot of the times both "zipcode" and "state" are mandatory fields.

Zipcode is easy, the platform likely wants my postal code.

You have to be a little bit more creative with state, sometimes "We don't have any states" is fun to see printed on your address label on a parcel, other times "Denmark" could be considered a state in the EU and that can be an answer, but most times "N/A" is enough.

krater23

a day ago

This already works on most shop systems in Germany. The OP just have to learn that zip codes aren't international. You can't know everything. Why this automation isn't implemented when you select USA as country...I don't know, but when you select Germany it works.

goloroden

a day ago

I entered my zip code… well, wrong country: I’m living in Germany.

And even if you knew that, the only thing you could have known from the zip code is the city. At least roughly, because multiple small villages share one zip code.

Or, to cut it short: This doesn’t work at all on a general and global level, so I guess there’s a reason why websites do this differently…

YokoZar

a day ago

The author complains about country selector drop-downs as part of the address flow, but if you're collecting zip codes you are already assuming United States. I don't think there's a country-inferer from completely generic postal code tool out there yet, is there?

nottorp

20 hours ago

> if you're collecting zip codes you are already assuming United States

From outside the US: I always thought "zip code" is just what you USers call a postal code. I only found out it's a trademark today, from this HN discussion.

So most people outside the US will see "zip code" and think "oh, they mean postal code but they have this weird term for it".

lsaferite

a day ago

You could maybe do it for some subset of countries, but it's not simple. And some countries don't have post codes.

pdpi

a day ago

In the UK, it's pretty common for the post code to be the first field in address forms, and for the form to then offer auto-completion for the whole address based on the post code. Postcodes are specific enough that the autocomplete will just give you a handful of addresses (e.g. my postcode will give you just the flats for the building I live in).

mttjj

a day ago

I definitely agree in principle. But - without doxxing myself - I input my zip and the city is not correct. It’s a very close neighboring suburb (where the boundaries are definitely blurry) but it’s not the city on all the legal documents for my current house.

matthewbauer

a day ago

Yeah city is not fully a function of zip. ~I think state is though.~* I believe when multiple cities share a zip code USPS uses the larger one. Usually the wrong city will get delivered though, probably not guaranteed.

* correcting myself, some zip codes do cross state lines

krater23

a day ago

Can't say anything about the US, but in Germany when more than one cities have the same zip code it's just not important because there is only one sorting center for all cities with the same zip and they just sort per street address.

ezfe

a day ago

Legal address doesn't matter for mail, and all of this stuff is about mail/shipping. This includes billing addresses.

I would have assumed that you knew that. I know people whose ZIP code belongs to a neighboring town (because mail works that way) and it basically becomes their de-facto address.

mttjj

a day ago

Probably not safe to assume my level of knowledge about any subject matter

petee

a day ago

Some areas have duplicate, or very similar street names (ie, 'ave' vs. 'street') I don't think its that much of an ask that a website lets you enter your address correctly

esrauch

a day ago

Yeah it should auto fill but not stop you from changing it, best experience 98% of the time.

I just looked it up and apparently there's some cases of zip codes that do go across state lines too, but it's rare.

ezfe

a day ago

There is a canonical full address for every mailbox in the US. Would be curious to see what these houses show.

My experience living in towns that received mail from other towns is your canonical address IS the other town.

esrauch

a day ago

FWIW I have received mail from the USPS in places that had no canonical full address as well. It's not the case in reality that the USPS only delivers mail to mailboxes that have an associated entry in their canonical database here in "messy" reality.

ezfe

a day ago

Street name isn’t auto completed here…

kube-system

a day ago

The legal address can absolutely matter for shipping when there are legal requirements in regards to the thing you’re shipping.

It's impressive someone went to the trouble of putting together this angry dreck, and completely ignoring the fact that ZIP codes often span multiple cities/towns, which not only completely invalidates the author's premise, it would populate the fields with wrong information that would have to be manually corrected later.

efitz

a day ago

Im reading through all these comments and it amazes me how the perfect is the enemy of the good, for many computer people.

Ofc there are edge cases. So since there exist a handful of edge cases where a zip code maps to two states, or the more frequent (but irrelevant in the US) case of two or more city names per zip code, we should make everyone suffer?

Ofc if you are making a web form you should ask for the zip code first, and auto complete state and city. Let the user edit them if they don’t like what you chose. Or do as some have suggested here and present the official USPS data as a drop down of 2 states or 2-3 cities; thats way better than having to type all of it.

And I curse everyone who thinks it’s a good idea to break zip code or phone number or OTP into multiple fields, or if you’re too lazy to set the input type to number.

djoldman

a day ago

Fun facts:

There are zip codes that map to more than one city.

There are zip codes that map to more than one state. (42223)

kazinator

a day ago

Looks like that is just an area that straddles the border between Tennessee and Kenucky. Though it maps to more than one state, it is a single, connected region.

Line houses are even more interesting: https://en.wikipedia.org/wiki/Line_house

macintux

a day ago

And as others are pointing out, there are zip codes which appear across multiple countries.

billforsternz

a day ago

It's very interesting how the "you know the city, the state, the country" mantra here is really "you know the city, the state and obviously the country is the USA no other possibilities are considered or worth considering"

teiferer

a day ago

I live in 10115. No, not New York. It's Berlin, Germany.

I used to live in M6C1B5. By forcing "numeric" on the zip code field, you'd immediately loose all Canadians.

This article is so US centric it's not even funny.

thiht

17 hours ago

> I type 90210. You now know I'm in Beverly Hills, California, United States

You CAN’T get the country from a zip code. France also use 5 digits zip code for example. You must ask for the country before asking for the zip code, even if you pre fill it with a sane default, like the main country you operate in.

sghaz

a day ago

The ZIP-first approach assumes a postal code can deterministically resolve the rest of the address, which is rarely true in practice since many codes map to multiple cities or large geographic areas. Making it reliable requires maintaining comprehensive, frequently updated postal datasets or integrating with external geocoding services, which introduces non-trivial operational complexity. Additionally, deviating from standard address field ordering can work against established user expectations and may degrade usability rather than improve it.

apendleton

a day ago

Zipcodes are not great for reliably describing locations. They're collections of multiple postal delivery routes, and that's it. There's no guarantee that any given zipcode lies within a single city, or a single state, or that it lies within the boundaries of the US at all, or that it's contiguous, or that it's stationary (there are some for boats), or that any given location only has one, etc., etc. People think this is a good idea because their particular case happens to work well, but zip codes are rife with edge cases.

rishikeshs

a day ago

I’m reading this from UAE where zipcodes don’t exist. I wanted to make a similar post so that when you select UAE as country remove the zip code field. Usually the workaround is to type 000000

tomburgs

14 hours ago

did an llm write this? how is it so confidently ignoring rest of the planet?

despite the obvious flaws others have already noted, plenty of countries include letters in their zipcodes, rendering the "Invoke the right keyboard" argument not only incorrect but potentially damaging to users or businesses who choose to follow this. if the website won't allow me to physically enter my zipcode, i'll just take my business elsewhere.

I like how instead of just rephrasing the website’s premise to make it clear he only cares about the US, he added some ip-based geolocation to select a snarky response based on where you are. Essentially the site argues back to you if you’re not in the US or something. Why did this person even bother creating the website if he’s so hostile and angry.

pentagrama

a day ago

Besides the issues of the OP approach that many point out on this thread, I also want to point out that the ZIP code input on the example, doesn't have the type=number so my mobile keyboard opens with the whole keys instead of the numeric keyboard, in this case that ZIP codes are only numbers, the type=number will improve accessibility.

hysan

a day ago

IMO, the spirit of the idea is to put higher information density fields first, and let that smooth out the UX for the remaining fields as you go downwards. Yes, there will be exceptions but that only matters if you’re trying to absolve the user of all work for 100% of situations. Trying to do that is a fools errand. Invert the order and use the information gathered to make inputting the rest simpler for 80% of the users. Then make it easy for the other 20% to course correct (ex: don’t disable autofilled fields, highlight all text when tabbing to the next field, etc). I think this pattern is a good one to keep in mind, but not blindly follow, when designing the UX of a UI.

dasil003

a day ago

When you create a site with a tone this self-righteous and condescending, you should really double check your thinking to make sure there is not some glaring flaw invalidating the premise for the majority of people in the world:

> A US ZIP code is 5 characters. From those 5 characters you can determine the city, the state, and the country. That's 3 fields. Autofilled. From one input.

I guess this is par for the course in Trump's America, but I still feel embarrassed for the creator.

valicord

a day ago

"You can determine any country as long as that county is USA"

bichiliad

a day ago

Besides the technical constraints (the zip code can't always tell you the city, etc), the zip code is more of a checksum to make sure the address you typed makes sense. I think you could probably get around the imperfections by making the city / state / zip be things suggested to you, whether in an autocomplete or by making them first in a dropdown. The imperfection of a zip code in encoding a city name doesn't mean that the frustration of filling out addresses isn't a real one!

zeehio

a day ago

It should be at least "Put country first, then ask for zip code".

08036 Barcelona, Barcelona, Spain

08036 Hainesport, New Jersey, USA

It does make some sense to go from most general (country) to more specific (address) instead of the opposite, so the form can implement better auto completions.

However in practice postal addresses are not that clean so simple dumb forms are usually better, because it's easy for exceptions to be missed by auto completion algorithms. I would be very pissed if I had to type the zip code above and then correct the wrong guess on every website.

Either you are helpful and guess correctly or you don't guess at all.

kube-system

a day ago

Or rather “country first and then postal code”. Zip code is a postal code but only one postal code is a zip code.

phippsytech

a day ago

This sound like it's more efficient - however... (and ignoring the US specific stuff)

Even in forms where I've designed this it breaks my flow as a user. I'm used to suburb state postcode order (I'm an Aussie). It's how we were taught to write the address in school. It's been a pattern for a long time, and the reversal of the fields slows my brain down.

IMHO The better user experience isn't changing the order of the fields. It's honouring auto-complete so the user doesn't have to enter this data in the first place.

DHPersonal

a day ago

Address entries are the weirdest places of frustration. Business clients want Google Places to make address input easier. This user wants a single ZIP code entry to begin the process. Why is adding one’s own address manually that huge of a hurdle that we have to separate the user from the inputs? If there is one person in the world who should know my address, it’s me: why then put such an effort into building a site that takes away my ability to enter my address?

hakfoo

a day ago

It's probably a turtles-all-the-way-down problem.

Three or four blank lines is probably the least hostile and most foolproof way to handle addresses.

But the cart software has distinct address-line-1, address-line-2, city, state, zip-code fields.

And the CRM they export into has similar fields.

Probably to be compatible with some further pipeline of tooling going back decades.

I suspect if you go back far enough it ends at pre-/semi-computerized data processing systems which would print addressed envelopes and documents from stacks of Hollerith cards, using extremely rigid fixed formats that were probably fine for their original buyers, likely US-centric and old enough that they were just getting it to the right city and letting the local postman figure out the nonsense on the envelope.

RASBR89

a day ago

In the last couple of years in the uk, address forms ask for you street address and the rest will autocomplete from there - city, postcode. Makes things a lot easier in the way the author suggests

osherse

14 hours ago

You know this is how we do it in the uk. Put in the post code then select the address. Post codes here are also really specific so usually it’s a few dozen addresses to pick from.

adangert

19 hours ago

It's generally easier to start typing your street address (maybe 4-5 characters), see an auto fill, click your address and all information, including the zip is already filled out.

If you started with just the zip you still have to type your street address afterwards.

twodave

a day ago

Most sites I use auto-fill city, state and zip once I type the street address, which is the 1 piece of my address that can’t be guessed from any of the others. So I’d say that’s probably the optimal path for most people, at least in the US. I’m sure people from other countries scoff at the US address suggestion and go straight for the country box from the beginning.

lsaferite

a day ago

Unfortunately you still need country first. But past that, the point stands well. You'll need to adjust the form based on the country, obviously.

For the US you can use zip-5 to prefill bunch of data and zip+4 practically fills it all out for a lot of addresses.

Each country has some particular nuance though, so it's only as simple as "zip first" or "postcode first" in some locations.

This failed when I put in an australian postal code.

Charon77

20 hours ago

In Japanese websites this is pretty much the norm. Govt, bank, marketplace, you name it. fills the address until the block, where you'll need to fill the rest of the numbers until your house address / room number

tsoukase

15 hours ago

While using imperial system and MM/DD/YY for dates, I doubt zip codes will follow a digital-frendly and world-aligned format.

c0balt

a day ago

Awesome idea, IF you are US only and don't cover edge cases and (want to depend on an external API or want to have some sort of eventually outdated map of city <> postcode).

It is possible to do this properly, e. G., DHL and UPS do a somewhat okay job of it but isn't easy.

chrysoprace

a day ago

As others have pointed out this is just US-centric, and doesn't work for most countries. The best option I can see is to have an autocomplete, and allow manual addresses with a country-specific form based on a country selection (or detection).

pauliusjac

20 hours ago

We tried this on one of our e-commerce sites and it mostly worked. But we had to scrap it once we started expanding internationally.

On a personal note, please just let my browser autofill my address.

kawsper

a day ago

My postal code is 2200 (København N), and that form didn't do anything for me.

All zip codes are postal codes, but not all postal codes are zip codes.

At my last gig, this sentence was said a lot, and people kept confusing the two, both in code and in daily speech, so maybe colloquially they are the same :)

jdlyga

a day ago

Zip codes do not have a one to one relationship to cities in the US. It's a common misconception. It's true about 90% of the time, but there are a lot of outliers. I used to work with GIS data and there are a ton of exceptions.

dgeiser13

a day ago

Some zip codes cover multiple cities.

wenc

a day ago

I think that can solved using a city dropdown there’s ambiguity.

This is not new. Some checkouts do start with zip code and they feel much more efficient. (US only delivery, so country already assumed)

acidburnNSA

a day ago

Yeah, but autofilling everything down to the neighboring city is still a huge improvement.

b5n

21 hours ago

All the extra steps serve as some type of verification + data collection.

The devs know how to make the experience better, but they get paid to implement some mbas mining scheme.

The future is ok but mostly sucks.

evrimoztamur

a day ago

In the Netherlands most websites use a common routing database to map a combination of a ZIP code and house number (+ suffix) to your exact address automatically. Great UX! And naturally depends on good administrative and postal services data quality.

talkvoix

a day ago

I completely agree with the premise, but if we just ask for the ZIP code first and auto-fill the rest, how am I going to justify my 2-week sprint to build a custom, React-based, fuzzy-searchable, virtualized dropdown component for the 'State' field?

Just kidding xP

timvisee

19 hours ago

The majority of comments complains about non-USA. But the author clearly states:

> Fine, maybe country first

It's an example - limit typing. But adjust it to your own use case.

estebarb

a day ago

I tried to put my postal code and it wrongly assumed that I live in the United States.

The zip first suggestion seems that would be really inconvenient for around 95.8% of the world population.

conductr

a day ago

I know some zips covers multiple cities. I would imagine some cross state lines in places too. Doesn’t cover multiple countries either as some have similar formats (5 digits). So there are edge cases that make this infeasible

Agreed, but:

JRandomCustomer enters street-number, apt-number, city, state, code ... in that order.

Also, many websites seem to have a negotiation with the browser, where, given: a street address, -> they can populate the other fields.

Definitely not perfect

Le sigh. It has now a disclaimer at the top. “Hello from across the pond (or whichever body of water separates us). This is a US ZIP code website. We are aware that other countries exist.”

This guy just keeps digging himself into a hole of ignorance - is he aware of Mexico? Canada?

8organicbits

a day ago

There's a few messages it can show:

      const msgs = [
        `Yes, we know ${country} exists. We're very proud of you.<br><br>This site is about US address forms — the ones that make <em>Americans</em> scroll past Turkmenistan 200 times a year. You have your own postal code problems. We believe in you.`,
        `We see you're visiting from ${country}. Welcome. We regret to inform you that this rant is specifically about American address forms, which are — and we cannot stress this enough — <em>unbelievably bad</em>.<br><br>Your country probably has its own postal code horrors. We'd love to hear about them: <a href='mailto:shame@zipcodefirst.com'>shame@zipcodefirst.com</a>`,
        `Hello from across the pond (or whichever body of water separates us from ${country}). This is a US ZIP code website. We are aware that other countries exist. We just have 160 million addresses and a 50-state dropdown to be mad about first.<br><br>Your frustrations are valid. Your postal codes are also useful. Put them first too.`
      ];

watusername

a day ago

None of which reflect well on the author. The "We're very proud of you." is exceedingly condescending.

Yeah, that was added after the onslaught. I’m in Canada and got the “across the pond” one. Lol.

fsckboy

a day ago

there should be one text box with multiple lines and you enter your address the way you would write it on an envelope. works internationally, gets stuff delivered. If the postal service can parse it, so can a website. Typing in your address will go so much faster than having to read the tags and navigate for every piece they are asking for. any redundancy can be used for error checking which is a good idea.

the "fields", like the goggles, they do nothing

petersumskas

20 hours ago

Keep going! The idea has merit. But it is US centric.

I tried the example with my local post code and of course it didn’t work as I’m not in the US.

hknceykbx

7 hours ago

How about autofilling zip code

senadir

a day ago

The kind of takes that promote the stereotypes of self-centered americans.

LeoPanthera

a day ago

Why do we not use ZIP+4 add-on codes anymore? Some sites won't even accept them. If you put that in first, you've narrowed it down to one street at worst, in most cases.

rerdavies

15 hours ago

How about you put the address line first, and I press the TAB key to autofill.

petee

a day ago

My zip covers two cities, each has a similar street name; 5-digits isn't enough.

I've encountered websites that take the zip and won't let me change the wrongly-assumed city

fjfaase

a day ago

The Dutch zipcode and the house number are unique. So, to mail something to the Netherlands anywhere from the world, it is enough to write something like: NL 1072CT 4.

aeternum

21 hours ago

Just make sure it works well with autocomplete. No additional fanciness or weird rearranging of fields is needed.

This works really well in Ireland. Eircodes (our late adoption postal codes) resolve to individual addresses rather than areas, so Irish sites mostly do this.

TRiG_Ireland

a day ago

You have to be careful with this. Building sites (translate that into American as "houses under construction") may want to order stuff, but won't yet have eircodes. Indeed, I believe that they're issued only twice a year, so new-built houses may not have them either. So you cannot make it a required field.

maxk42

a day ago

The US also has postal codes that map to individual addresses. People just don't know them.

vscode-rest

a day ago

I wonder if people had a similarly negative reaction when someone first proposed speculative execution in processor pipelines.

“This is is a terrible idea, you’re telling me you will make 99% of cases way faster but completely ignore the 1% that will be slightly slower? Unbelievable.”

If you have SA that most of your customers are in USA, this is a good idea. If not, maybe use your brain a bit and figure out if it can be adapted to something which will work for your customer base.

sib

a day ago

ZIP codes don't uniquely identify cities / towns. (Or, in fact, States). Not to mention, they certainly don't work globally...

kube-system

a day ago

> You didn't need me to scroll past Turkmenistan.

You’d absolutely have to determine that you’re in the US before asking for zip code.

zjp

21 hours ago

At least detect my country by IP range and put "US" at the top of the country dropdown.

1970-01-01

a day ago

Go with 20252 when you know they're just collecting it to send junk mail. Many programmers don't even try to filter for it.

joshellington

a day ago

I wish I could downvote this. Please don’t do this folks. Editing “guessed” filled inputs when they’re incorrect is a higher UX bar of effort than browser autofill or even just typing it (especially on mobile). Plus a non-zero number of users will just not correct or be confused and abandon.

zackify

a day ago

I only ask for zip on our checkout. And get the email from one tap methods.

Like the author I cannot stand how stupid some checkout processes are!

I guess a better proposal would be:

- Put the country first

- Put the zip code second

tomjakubowski

a day ago

Use ZIP Code: the last word in mail address.

throwaway0665

a day ago

It doesn't take long to type your address. Plus password managers or keyboards often auto fill it. It's not that deep.

aed

a day ago

> If you're asking for a ZIP code, use inputmode="numeric"

Does this work for zips? Some zips have a leading 0.

Related, on the country drop-down front: please put the United States (or whatever your customers' main country is) at the top. You can probably tell I want the US from a combination of, you know, 99% of your sales being to the US and my language being set to English. And, sure, put Canada and even the UK next to it. Go wild, have the top ten English-speaking countries there if you like! It makes things so much easier.

The trick, then, is that you don't remove anything from the alphabetical list. With modern computer technology, we can have two places to find something! So if I miss your fancy shortcut, or it's not applicable to me, everything will still be in the regular old familiar place. It just works.

hbrav

a day ago

This generates a really annoying features with some browsers. Suppose I want to select "United Kingdom". I open the drop-down and there are all the countries in alphabetical order, plus "United States" at the top of the list. I hit the 'U' key. It does not take me to the alphabetically listed countries beginning with 'U', it takes me to the "United States" entry at the top of the list. I might be able to type 'U-N-I-T-E-D-K' and get to the "United Kingdom" entry, but there are browsers where that does not work. (Nor does repeatedly hitting 'U' bring me to the later 'U' entries.)

jmull

a day ago

Autofill seems like a better solution.

Ehh... US-centric. Better to use significance order: Country, then postal (most countries have postal), then region, city, and street address. Best, however, is to _not_ separate the address into fields. Instead, allow a free text field for the person doing data entry to put in the address in _their_ format and then parse it on the backend. This gets you the most flexibility and allows you to encounter and handle corner cases by using (my favorite test data) public addresses from all over the world. _I_ routinely test my address entry by Googling McDonald's locations and feeding them into my system. Handle an inscrutable address like any other bad data and say, politely, that your system does not understand the data.

All that said, free-form entry is a hard sell. My _customers_ expect field data entry, so I implement field data entry. I just re-order my checks to be more forgiving until the data entry is complete.

I was implementing a customer service address entry using significance order 25 years ago. As I already _knew_ that I had a US-centric customer base (we sold long distance to sorority and fraternity members), entering US ZIP first saved a lot of time and more highly leveraged the US postal address cleaner that we had already purchased for our mass marketing mailers. The people working the call center _loved_ it, as they could focus more on their call turn-over than on data entry.

agnishom

a day ago

Somehow a lot of Japanese websites use this trick. Far more often than USian websites.

muppetman

a day ago

The ignorance of this post to the rest of the world is amazing.

LowLevelKernel

20 hours ago

Phew! Somebody had to say it. Finally thank you

paulddraper

a day ago

Flawed premise.

This works within a country, but not between countries.

For example 77520 is the zip code of Cancun, Mexico and Baytown, Texas.

---

Needs to be country + zip code (postal code).

sakesun

a day ago

Likewise, we should all use ISO 8601 date format.

fenwick67

a day ago

Galaxy brain: address should just be a multi-line field

pbnjay

a day ago

Um a lot of US zip codes map to multiple cities. Some even to multiple states. If you build a picker for city/state this works fine but your premise is easily refuted if you look at the data!

Zip codes map to postal routes, not polygons

junon

a day ago

"See how you typed 5 numbers and three fields filled themselves in?"

Nope! Didn't see that. Seems the zip code registry doesn't have a number of German zip codes.

jeffrallen

19 hours ago

A little too US centric. With a bit more effort it would detect all of the G20's post code formats and fill in the country name automatically. (Sparing me the frustration of trying to choose between Switzerland and Swaziland in the 6 point font you chose for the pop-up.)

Also, don't be a dick. Have some empathy for your reader. Half of the UI designers you are talking to don't have a choice in how it works. Their colleagues chose some stupid framework which they can't customize. The other half didn't even want to do this task, they just got it assigned to them by some PM they don't respect (who, in turn, does not respect any advice coming from UI designers), and they are doing the minimum they possibly can while applying to other jobs that suck less.

nomdep

a day ago

If you’re going to ask for a country, ask for it first.

Zip codes repeat across countries, you know.

krater23

a day ago

Maybe first start with using non subhuman units like meter and celsius, then learn that there are other countries than 'The United States of America' and then fix that with the zip codes. ;P

p.s.: Don't takt this too serious, have just a dark kind of humor.

hluska

a day ago

In a similar tone, it’s 2026. Why are we still messing with form ordering instead of leaning into autofill? So somehow it makes more sense to change every single address form in existence to a non standard order because…why exactly? There’s a whole world outside of the United States with many formats for postal codes. It’s more efficient to just use autofill…

hirvi74

a day ago

While interesting, it would take me more time to implement and validate this logic than it would take the user to enter the data.

enraged_camel

a day ago

I would say this doesn't actually work well for UX, because people are more likely to know their street address and city than their zip code. Personally, every time I've moved over the years, it took a few weeks for me to internalize my new zip code.

The US Postal service has some of the most complex software in existence, including some of the most advanced handwriting recognition ever developed.

The fact that mail gets to its destination when it does, as soon as it does, with overall minimal error, is nothing short of amazing.

But some web dev blogger has it All. Figured. Out.

Right.

I'm sure your way is better.

This is big "I could code it in a weekend" HN energy.

The USPS owes you a debt of gratitude for buying a snarky domain and bringing this to their attention after 63 years.