Parse and normalise street addresses

Split a free-text US address into street, city, state and ZIP, check the parts against ZIP code data, and build a standard key for finding duplicates and shipping.

  • 35 min
  • 3 parts
  • Intermediate

Addresses arrive in two ways. Either your form has separate fields for street, city, state and ZIP, and people still paste the whole thing into the first one, or you import addresses from somewhere else, a CSV from a trade show or a legacy CRM, where they were always one string. Both end in the same place: 350 5th Ave Apt 21B, New York, NY 10118 and 350 Fifth Avenue #21B New York 10118 are the same apartment, and nothing in your database knows it.

This lesson builds the three steps that fix that: parse the string into parts, check the parts against reference data, and assemble a normalised key. It uses Street Address Parser and Zip Codes Lookup, both 2 credits a call, with Cities Lookup for the cases where all you have is a city name.

One limit up front, because it shapes everything else: these tools parse and cross-check. They do not certify that a mailbox exists at the address. That needs postal-authority data such as USPS address certification, and it is a different, more expensive product. What you get here is cheap structure, which is what dedupe and most shipping forms actually need.

01What the parser returns

Start with a clean US address:

Try it liveStreet Address Parser2 credits
GEThttps://api.apiverve.com/v1/streetaddressparser
curl "https://api.apiverve.com/v1/streetaddressparser?address=1600+Amphitheatre+Parkway%2C+Mountain+View%2C+CA+94043" \
  -H "x-api-key: YOUR_API_KEY"
Sign in or create a free account to run this with your own key.

streetAddress is the street NAME (Amphitheatre); the number and the type are separate fields.

The documented fields sit under data.parsed: streetNumber, streetAddress, streetType, cityName, stateName and zipCode. Two of them are named in ways that cause bugs. streetAddress is the street name alone, Amphitheatre, not the full street line. stateName is the two-letter abbreviation, CA, not California.

The parser does real normalisation work on the street type and directionals. Parkway, parkway and Pkwy. all come back as Pkwy; street comes back St; Terrace comes back Ter; and the word north in 123 north main street comes back as streetPrefix: "N". A ZIP+4 such as 94043-1351 is cut to zipCode: "94043". It does not change the case of names, though: springfield il stays springfield and il. You will uppercase those yourself.

Unit numbers come back in fields that the published definition does not list yet, so code defensively around them. Observed in real responses:

{
  "sec_unit_type": "Apt",
  "sec_unit_num": "21B",
  "streetNumber": "350",
  "streetType": "Ave",
  "streetAddress": "5th",
  "cityName": "New York",
  "stateName": "NY",
  "zipCode": "10118"
}

#2 comes back as sec_unit_type: "#" and sec_unit_num: "2"; suite 400 as suite and 400. Parts that are not present are omitted from parsed, not set to null. Parse just 1600 amphitheatre parkway and you get three keys and no city at all. Read every field with a default.

Check yourself

The parser returns streetNumber 1600, streetAddress Amphitheatre, streetType Pkwy. What should you print on the first line of a shipping label?

Run every example on your own key. Free plan, no card.

Scaling up?

Volume pricing, custom SLAs, and dedicated support for high-traffic teams.

Contact sales