Skip to content

Distance Between Cities

Calculate the straight-line distance between two city centers in miles and kilometers. Add a state after a comma when a city name is ambiguous, such as Portland, ME.

A state after the comma picks the right one: Portland, ME.

Make sure it is the right city

Portland in Maine and Portland in Oregon are different endpoints. The returned city and region identify the place used in the calculation. A distance can look plausible even when one name resolved to the wrong city.

City-center distance is not a road route

The calculation measures the shortest path along the Earth's surface between the cities' reference coordinates. A journey between particular addresses can be longer and have different endpoints. This page does not calculate directions or travel time.

Use it in your app.

Get city coordinates for maps, location search and distance calculations.

Request

import { parseAPI } from '@parseapi/sdk';

const parse = parseAPI("YOUR_API_KEY");
const result = await parse.city("Denver", { country: "US", state: "CO" });
console.log(result);

City API documentation

How is the distance between cities calculated?

The calculator resolves each city to reference coordinates, then applies the great-circle formula. This is air distance, also called straight-line distance, between city centers. The result includes miles, kilometers and the two resolved places. Copy distance keeps them together.

How do I choose between cities with the same name?

Add a state after a comma, such as Portland, ME. Read the two returned place names and regions before using the total.

Does this calculate driving distance or travel time?

It calculates straight-line city-center distance. Driving, flight itineraries, traffic, and journey time require route-specific information.

Why can this differ from an airport-to-airport distance?

An airport and a city center are different points. Even the same city pair can have a different distance when different airports or addresses are used.

Can I enter ZIP codes instead?

Use the ZIP distance calculator for postal-code endpoints.

Why was a city not found?

Check its spelling and add a state when applicable. Both cities must resolve to usable coordinates; an unknown endpoint is not assigned an estimated distance.