Skip to main content

Address geocoding format guide

Forward geocoding converts location text into geographic coordinates, turning 2 Lincoln Memorial Circle NW into -77.050,38.889. A basic Geocoding API request with an address looks like:

https://api.mapbox.com/geocoding/v5/mapbox.places/2%20Lincoln%20Memorial%20Cir%20NW.json?access_token= <UserAccessToken /> 

Use the following address formatting guidelines to make sure that your Mapbox Geocoding API requests retrieve the right results.

Encode the address correctly

The search text must be expressed as a URL-encoded UTF-8 string. The address cannot contain the semicolon character ; (either raw or URL-encoded).

  • 2%20Lincoln%20Memorial%20Cir%20NW
  • 2 Lincoln Memorial Circle NW

Unencoded, the address must be 20 words and numbers or less, separated by spacing and punctuation. The unencoded address can be 256 characters at most.

Use one building number, not a number range

Use a single building number rather than a range of numbers when constructing a query.

  • 123 Main St
  • 123-127 Main St

Format address components consistently

Addresses in the United States

For addresses in the United States, pass in the address components in the format {house number} {street} {city} {state} {zip}.

  • 123 Main St Boston MA 02111 (US)

Addresses outside the United States

For geocoding in countries other than the United States, you have a few options. You can either submit the components in the same order as you would use for an address in the United States ({house number} {street} {city} {state} {zip}), or you can follow local address formatting standards for those countries.

  • 123 Main St Swindon SN2 2DQ (UK)
  • Fraunhoferstraße 6 80469 München Bavaria (Germany)

Addresses in multiple countries

If you need to pick one standard order to use for multiple countries, pass the address components to the geocoder in order from most granular to least granular: {house number} {street} {postcode} {city} {state}.

  • 123 Main St 02111 Boston MA (multiple countries)

Use the country parameter

If you need to limit results to one country, use the country parameter in the API request instead of including the country in the search text. The country parameter will limit results to only locations within the specified country.

✅  Results will only include locations within the United States
https://api.mapbox.com/geocoding/v5/mapbox.places/123%20Main%20St%20Boston%20MA.json?country=US&access_token= <UserAccessToken />

❌ Results could potentially include locations outside of the US
https://api.mapbox.com/geocoding/v5/mapbox.places/123%20Main%20St%20Boston%20MA%20United%20States.json?&access_token= <UserAccessToken /> `

Zip code formatting

For addresses in the United States, you can use either the five- or the nine-digit zip code. Both zip code formats will return the same coordinate results when used in a forward geocoding query.

  • 02919
  • 02919-3232

Secondary address information

Secondary address information like apartment or suite number does not influence the coordinate results returned by a forward geocoding query. A query that uses this secondary address information, as well as any associated special characters like commas (,) and pound symbols (#), will return the same coordinates as a query with this information stripped out.

  • 123 Main St
  • 123 Main St #456
  • 123 Main St, Suite 7
  • 123 Main St, Building A
Was this page helpful?