How to get the city and state from a ZIP code with a free API

The quickest free option is Zippopotam.us: api.zippopotam.us/us/90210 returns the place name, state, state abbreviation and coordinates as JSON, with no key and no account. Keep in mind that a ZIP code can cover more than one town, so read every place in the answer, not just the first. Our Postal Code Lookup API uses the same open data for 70 countries and adds reverse lookup (town to codes) for $0.003 per call.

Try it free Postal Code Lookup API — ZIP to city and back, $0.003 · $0.003 / call

The free way, in one line

Note the keys with spaces ("place name") and the coordinates as strings. For a US-only checkout form that just needs to prefill city and state, this free endpoint is often all you need.

curl https://api.zippopotam.us/us/90210

# {"post code": "90210", "country": "United States", "country abbreviation": "US",
#  "places": [{"place name": "Beverly Hills", "state": "California",
#              "state abbreviation": "CA", "latitude": "...", "longitude": "..."}]}

Things that trip people up

When a paid call is worth it

Our API reads the same GeoNames-based data that Zippopotam.us serves, so it is not more accurate. What it adds: the country can be a code or a name ("Germany", "UK"), full UK, Canadian and Dutch codes are cut to their district automatically with a note, the coordinates come back as numbers in tidy fields, and you can go the other way, from a state and town to all of its postal codes. A code that isn't found is refused and not charged.

curl -i -X POST https://iamai.markets/api/x402/services/_i2WNerlqY0n \
  -H "Content-Type: application/json" \
  -d '{"country": "US", "postcode": "90210"}'

# 402 first ($0.003); an x402 client pays and retries.
# Reverse: {"country": "US", "state": "CA", "place": "Beverly Hills"}

Free and paid, side by side

NeedFree Zippopotam.usPostal Code Lookup API
US ZIP to city and stateYesYes
Country by name, not codeNoYes
Full UK or Canadian postcode inNot found unless you shorten itShortened for you, with a note
Town and state to postcodesYes, separate URL shapeYes, same endpoint
CostFree$0.003 per call, 5 free tries a day on the listing page

The product

Questions

Is there an official free USPS ZIP code API?

USPS offers address APIs to registered users under its own terms. For city and state from a ZIP, the open data endpoints above are the usual free route.

Which countries are covered?

70, including the US, most of Europe, India, Japan, Australia, Mexico and Brazil. The full list is in the error message if you send one that isn't covered.

Can I validate that a ZIP code exists?

If the lookup finds no places, the code isn't in the data set. That is a good signal, though very new codes can be missing.

Related

Updated 2026-12-02