Distance Calculator

Runs entirely in your browser

Calculate the straight-line (great-circle) distance between two latitude/longitude coordinates in kilometers, miles and nautical miles, plus the compass bearing between them, with both points plotted on an interactive map. The calculation runs entirely in your browser — only the map's tile images are loaded from OpenStreetMap.

Advertisement
Point A
Point B
0 Kilometers
0 Miles
0 Nautical Miles
Initial bearing
Method
Haversine (great-circle)

Map tiles are loaded from OpenStreetMap, so Point A and Point B's coordinates are sent to their servers to display the map above. No other part of this tool sends data anywhere.

Advertisement

How to use Distance Calculator

  1. Enter the latitude and longitude of Point A, or click "Use My Location" to fill it in automatically.
  2. Enter the latitude and longitude of Point B.
  3. The distance in kilometers, miles and nautical miles, plus the compass bearing, updates instantly.
  4. Use "Swap points" to reverse Point A and Point B, or "Reset to defaults" to start over.

Features

  • Calculates the great-circle distance between any two coordinates using the Haversine formula.
  • Results shown in kilometers, miles and nautical miles at the same time.
  • Initial compass bearing from Point A to Point B.
  • Interactive map showing both points with the great-circle route drawn between them.
  • "Use My Location" fills in Point A from your browser's geolocation, with your permission.
  • Swap points with one click.
  • The distance and bearing calculations are 100% client-side — only the map tiles are loaded from OpenStreetMap.

Worked Example

Point A: Mumbai (19.0760, 72.8777). Point B: Delhi (28.6139, 77.2090).

Δlat = 28.6139 − 19.0760 = 9.5379°
Δlon = 77.2090 − 72.8777 = 4.3313°

a = sin²(Δlat/2) + cos(lat A) × cos(lat B) × sin²(Δlon/2)
c = 2 × atan2(√a, √(1 − a))
distance = 6371.0088 km × c ≈ 1,148 km

≈ 713 miles
≈ 620 nautical miles
Initial bearing ≈ 22° (NNE)

The figures above are approximate, worked by hand using the same Haversine steps the calculator runs — enter the two coordinates yourself to get the exact result to two decimal places.

Things to know about great-circle distance

  • The Haversine result is the shortest path "as the crow flies" over the Earth's curved surface — it's always shorter than the distance you'd actually drive or fly, which has to follow roads, air corridors or avoid terrain.
  • The bearing shown is the initial bearing only. On a great-circle route longer than a short hop, your actual compass heading gradually changes as you travel, except when heading due north/south or along the equator.
  • Treating the Earth as a perfect sphere (radius 6,371.0088 km) instead of its true oblate shape introduces up to about 0.5% error — negligible for travel planning, but not appropriate for land surveying or aviation-grade navigation.
  • When the great-circle path between two points crosses the antimeridian (180°/-180° longitude), the map route is unwrapped so the line doesn't appear to jump across the entire map.

How does the Haversine formula work?

The calculator converts both points' latitude and longitude to radians, then finds the "haversine" (half the versine) of the difference in latitude and of the difference in longitude — each is sin²(Δ/2). Combining those with the cosines of the two latitudes gives a single value a that captures how far apart the points are on the surface of a sphere. 2 × atan2(√a, √(1 − a)) turns that into an angular distance in radians, and multiplying by Earth's mean radius (6,371.0088 km) converts the angle into a straight-line distance along the curve. The same Δlat/Δlon terms also feed the initial-bearing calculation, using atan2 on the north/east components of the great-circle path.

Where do I find latitude and longitude?

Most mapping apps show coordinates when you tap and hold a location, or in a share/link menu. In decimal degrees format, latitude ranges from -90 (South Pole) to 90 (North Pole), and longitude ranges from -180 to 180, with negative values representing the Southern and Western hemispheres. For example, New York City is approximately 40.7128, -74.0060.

Is Distance Calculator safe to use?

Yes. The distance and bearing calculations run entirely in your browser and are never sent to our servers. The one exception is the map: to display the map tiles, Point A and Point B's coordinates are sent to OpenStreetMap, the third-party service that supplies the map imagery — this is required for any map to render and is the same way most map-based websites work. If you use "Use My Location," your device's geolocation prompt asks for your permission first, and the resulting coordinates are only used to fill in the form and plot the map — they are not stored on our end.

Frequently Asked Questions

How is the distance between two coordinates calculated?

Distance Calculator uses the Haversine formula to work out the great-circle distance between two latitude/longitude points — the shortest path between them along the surface of a sphere approximating the Earth.

How accurate is this calculator?

The Haversine formula treats the Earth as a perfect sphere, so results are typically accurate to within about 0.5%. This is more than sufficient for most everyday, travel and logistics uses, though it isn't intended for high-precision surveying.

What format should I use for latitude and longitude?

Enter coordinates in decimal degrees, such as 40.7128 for latitude and -74.0060 for longitude. Latitude must be between -90 and 90, and longitude between -180 and 180. Negative values represent south (latitude) or west (longitude).

Can I use my current location?

Yes. Click "Use My Location" under Point A and, if you allow location access, your browser's built-in geolocation fills in your current coordinates automatically. Your location is used only in your browser and is never sent to our servers.

What is the bearing shown in the results?

The initial bearing is the compass direction you'd need to head in at Point A to travel the great-circle path toward Point B, shown in degrees (0-360°) and as a compass direction like NE or SSW.

Does the map send my coordinates anywhere?

The distance and bearing calculations never leave your browser. To draw the map itself, Point A and Point B's coordinates are sent to OpenStreetMap so it can return the matching map tile images — this is required for any map to display and is how virtually all map-based websites work.

Related tools