Getting San Francisco Zip Codes Right

San Francisco uses a bunch of different zip codes that don't map neatly onto neighborhoods the way people expect. The standard list runs from 94102 through 94188, but the real problem isn't looking up a number. It's figuring out which one actually applies when you're trying to send something, set up a delivery radius, or verify an address for a business account. I've had developers waste three days on a mapping issue because they assumed 94103 and 94105 were close enough to treat as the same zone. They're adjacent, but they route to completely different fulfillment centers. Here is what the codes actually are and where they show up in practice. 94102 covers the Tenderloin and parts of downtown near Market Street. 94103 is South of Market, including the SoMa warehouse district. 94104 is the Financial District proper. 94105 picks up the Embarcadero and waterfront area. 94107 runs through Potrero Hill and the industrial corridor near the highway. 94108 is Chinatown and Union Square. 94109 is the Hayes Valley and Lower Nob Hill stretch. 94110 is the Mission District. 94111 is Telegraph Hill and North Beach. 94112 covers the Visitacion Valley and central Excelsior areas. 94114 is the Castro and Glen Park. 94115 is Upper Market and the Lower Haight. 94116 is the outer Sunset near the park. 94117 is the Haight-Ashbury and Alamo Square area. 94118 is the Richmond districts west of the hill. 94121 is the outer Richmond near the ocean. 94122 is the Sunset near Balboa Park. 94123 is the Marina and Cow Hollow. 94124 covers the Bayview and Hunters Point industrial areas. 94127 is Balboa Terrace and Forest Hill. 94129 is the Presidio and the naval base area. 94130 is the Presidio address for military mail. 94131 is the Visitacion Valley and Crystal Springs area. 94132 is the Oakdale and Sunnydale neighborhoods. 94133 is North Beach and Russian Hill. 94134 is the Ingleside and Taraval corridor. 94158 is the dogpatch and tech campus area near Mission Creek. 94188 is a folded code used for PO boxes and large-volume receivers downtown.

USPS assigned these codes based on delivery routes, not city boundaries. A single street can span two zip codes if the mail carrier routes split between them. The 94158 code is a good example. It was carved out specifically for the Salesforce area and the surrounding tech offices. If you put a business address there into a shipping calculator that only knows the older 94107 routing, your delivery time estimate will be wrong by a day. I learned this the hard way when a logistics partner kept rejecting my address validation because their database hadn't been updated after 2010. The workaround was switching to a USPS ZIP Code Lookup tool that pulls from the current Carrier Route dataset instead of a static CSV file. It takes about ten seconds to cross-check and saved us from a whole shipment getting returned. People often treat these codes as neighborhood labels. They are not. 94110 and 94112 might feel like they should be close, but they serve completely different mail streams. Another issue is the PO box overlap. Some addresses show a street zip and a PO box zip that are different. If you only validate the street side, the postal system still expects the PO box code for that building. I ran into this with a commercial client who managed a shared office space. Their leases listed the street address, but the mailroom had a cluster of PO boxes under a different zip. Package deliveries kept getting flagged as misrouted until we mapped each suite to its correct mailbox zip rather than the building address. There is also the issue with high-rise buildings. A single skyscraper can have multiple zip codes depending on which entrance or tower section you use. The Transamerica Pyramid area splits between 94104 and 94105 depending on how the address is written. If you are building an address validator, you need to accept both and let the USPS CASS system decide which one is correct at submission time. Hardcoding a single zip for these buildings causes rejection rates that can exceed 15 percent in our experience.

Practical Validation Approach

The fastest method is to run addresses through an API that uses the USPS Address Information System. It returns the correct zip, the carrier route, and the delivery point check digit in one call. This cuts down validation time from manual lookups that can take minutes each to roughly two hundred milliseconds per address. If you are processing a batch, doing it in parallel with a few thousand calls per hour works fine. Rate limits usually kick in around ten thousand requests per minute, so most small to mid-size workloads won't hit that ceiling. For offline work or when you cannot connect to an external service, download the USPS ZIP Code Tabular File. It comes as a CSV with every valid zip, the city, county, and state. You can load it into your database and do local joins. The file updates monthly. Using a stale version from six months ago will miss newly created zones like 94158, which explains why some older tools still break on modern SF addresses.

Get the Full Details

San Francisco Zip Codes By Population at Marvin Wolbert blog
San Francisco Zip Codes By Population at Marvin Wolbert blog

Edge Cases Worth Noting

Military addresses on the Presidio use 94129 for civilian mail and 94130 for APO/FPO/DPO routing. They look the same on a map but belong to entirely different postal systems. Do not mix them. Also, the 94188 code is a folded zip assigned to the main downtown post office. Some online forms treat folded zips as invalid because they expect a five-digit delivery zip. If you are building a form, allow folded zips explicitly rather than filtering them out. I lost a client last year because their payment processor rejected 94188 as a fake code. We had to add a whitelist exception for it in the validation rules. If you need the raw data, the USPS website offers the ZIP Code Tabular File and the Address Information System documentation. Both are free. The tabular file is the simplest starting point. The AIS API is the one worth using for anything beyond a lookup page.