GetMyLocations

Free Tool · Pure JavaScript Math

Distance Calculator — between two GPS coordinates

Enter two latitude / longitude pairs and get the great-circle distance in kilometers, miles, nautical miles, and meters, plus the initial bearing from one point to the other. Uses the Haversine formula. Pure JavaScript — no API call, no signup, runs entirely in your browser.

Calculate distance

Point A (origin)

Decimal degrees only. Example: 48.858420

Point B (destination)

Defaults to Statue of Liberty. Edit to suit.

Requesting your location…
Kilometers
Miles
Nautical miles
Meters
Initial bearing
Compass direction
Formula
Haversine
Earth radius used
6,371,000 m

What is a distance calculator?

A distance calculator tells you how far apart two locations are. The version you're using right now takes two pairs of latitude and longitude coordinates and returns the straight-line distance over Earth's surface — known formally as the great-circle distance. This is the path a bird (or an airliner) would fly if there were nothing in the way.

Most people first run into great-circle math when they compare a flight time to a driving time and notice the flight is much shorter than the road distance would suggest. That's because aircraft follow the great-circle route while roads have to wrap around mountains, lakes, and political borders. The calculator below uses the standard Haversine formula — a one-line trigonometric equation that gives sub-half-percent accuracy for any pair of points on Earth.

How to use this calculator

  1. Enter Point A coordinates in the left card. Either type a latitude/longitude pair you already have, click one of the preset pairs above (Eiffel Tower, London, Karachi, NYC), or click Use my location to fill it from your device's GPS.
  2. Enter Point B coordinates in the right card. Any second pair — a destination, landmark, or coordinate from a different app.
  3. Click Calculate distance. The distance appears in four units simultaneously: kilometers, miles, nautical miles, and meters. The bearing (compass direction from A to B) is shown below.
  4. Verify on the map. A blue line is drawn between the two points along the great-circle path. Use this to sanity-check that you entered the coordinates correctly — a 10,000 km result with two points one block apart usually means a typo.
  5. Try variations. Click Swap A and B to flip the bearing (distance stays the same). Edit any field and click Calculate again; the map updates each time.

What is the great-circle distance?

The great-circle distance is the shortest path between two points along the surface of a sphere. Because Earth is roughly spherical, it is the natural way to measure how far apart two places are. It is what airlines use when they quote a flight distance ("LAX to LHR — 5,439 nautical miles") and what naval and aviation charts assume when they show a "rhumb line" alternative.

A handy mental rule: 1° of latitude ≈ 111 km everywhere on Earth. 1° of longitude ≈ 111 km at the equator, shrinking to zero at the poles. So two points at the same latitude differ by roughly (longitude difference) × 111 × cos(latitude) km — useful for sanity-checking the calculator's output without a phone.

What great-circle is not: it is not driving distance (which follows roads and is always longer), and it is not flight distance (which is great-circle plus wind correction and traffic-control re-routing). For driving routes specifically, use our Driving Directions tool instead.

Why use GetMyLocations?

Instant math

No API call, no round-trip — the Haversine formula runs in your browser and the result is on screen the moment you click.

Four units at once

Kilometers, miles, nautical miles, and meters displayed side by side — no toggling, no mental conversion.

Bearing included

See the initial compass heading from A to B in degrees and as a 16-point compass direction, useful for navigation and sanity checks.

Visual confirmation

Both points and the great-circle line drawn on a real map — the fastest way to spot a typo in a coordinate.

No signup, no ads-tracking

Works without an account. The math is open and free — Haversine has been in textbooks for 150 years.

Famous-pair presets

One click loads Karachi-Lahore, London-Paris, NYC-Sydney, or Eiffel-Liberty — handy for verifying the tool is working as expected.

Frequently asked questions

Which formula does this calculator use?

The Haversine formula, which gives the great-circle distance between two points on a sphere. It is accurate to within about 0.5% for any pair of points on Earth — far more than enough precision for trip planning, real-estate searches, geofence sizing, and most engineering uses.

Is this the same as driving distance?

No. Great-circle distance is the straight-line distance over Earth's surface. Driving distance follows roads and is always longer — sometimes dramatically so when mountains, water, or borders are in the way. For driving estimates use our Driving Directions tool.

How precise is the result?

The Haversine formula assumes a perfect sphere. Earth is a slightly flattened ellipsoid, so errors run about 0.3 to 0.5%. A 1,000 km calculation might be off by 3 to 5 km. For sub-meter accuracy on very long distances, surveyors use the Vincenty formula instead.

What units does it support?

The tool always displays four units at once: kilometers, miles, nautical miles, and meters. Pick whichever your downstream use case wants — no unit switcher to remember.

Can I enter DMS coordinates?

This calculator takes decimal degrees only. Use our Coordinates Converter to translate DMS like 48° 51' 30.3" N into decimal first, then paste the result here.

What does the bearing field mean?

Bearing is the initial compass direction (in degrees from true north, 0 to 360) that you would head if you started walking from Point A toward Point B along the great-circle path. is due north, 90° is east, 180° is south, 270° is west.

Does this work offline?

The calculation itself runs entirely in your browser, so it works without a network. The map underneath fetches tile images from OpenStreetMap, so the visual confirmation needs a connection.

Related tools on GetMyLocations