Two plotted points joined by a straight line marked with its length

Distance Calculator

Two points on a plane, two points in space, or two coordinates on the Earth

Unit free. Enter metres and the answer is in metres, enter pixels and it is in pixels. Keep both points in the same unit.

Load an example
Distance on the plane
…

Which distance question is yours?

The word distance covers several different jobs, and picking the wrong one is the most common way to get a confidently wrong number. Find your row, then set the mode above to match. The last four rows are questions this page deliberately does not answer, with the page that does.

What you haveWhat to doMode
Two ordered pairs on graph paperd = √(Δx² + Δy²), straight inPlane
One point and the originEnter (0, 0) as point A, or read the origin rows in the panelPlane
Two pixel positions on a screenSame formula. Screen y grows downwards, which changes nothingPlane
Two corners of a rectangular roomUse the plane for the floor, or add the ceiling height as zPlane
Two vertices in a 3D model or a game worldd = √(Δx² + Δy² + Δz²)Space
Two survey points with an elevation eachPut the easting and northing in x and y, the height in zSpace
Two GPS coordinates in decimal degreesHaversine on a sphere of radius 6,371.0088 kmEarth
Two coordinates in degrees, minutes and secondsConvert first with dd = d + m/60 + s/3600, then use Earth modeEarth
A heading to steer as well as a distanceRead the initial bearing row, in degrees and as a compass pointEarth
A distance at sea or in the airRead the nautical mile row, one minute of latitude is one nautical mileEarth
Two street addresses or postcodesLook up each one on a map first, then paste the coordinatesNot here
The distance you would actually driveThat follows a road network and needs a routing engine, not a formulaNot here
The perpendicular distance from a point to a lineA different formula, |Ax₁ + By₁ + C| / √(A² + B²)Not here
A missing side of a right triangleThat is the theorem itself, on the Pythagorean theorem calculatorNot here
Guide

Distance between two points, on paper and on the planet

The flat formula, the third dimension, and why latitude and longitude need a different one entirely.

There are two completely different questions hiding behind the phrase distance calculator, and mixing them up is the fastest way to a confident wrong answer. The first is coordinate geometry: two ordered pairs, a flat plane, and the distance formula d = √((x₂ - x₁)² + (y₂ - y₁)²). The second is geography: two latitude and longitude readings on a curved planet, where that flat formula is not approximately right, it is structurally wrong. This page does both, keeps them clearly apart, and draws the answer so you can see which one you asked for.

Start with the flat case, worked through once. Take A at (5, 6) and B at (-7, 11). The horizontal run is -7 - 5 = -12 and the vertical rise is 11 - 6 = 5. Square them and you get 144 and 25, which add to 169, and the square root of 169 is exactly 13. The negative sign on the run disappeared the moment it was squared, which is the whole reason the formula is safe to use in any order. The midpoint, which falls out of the same two points for free, is (-1, 8.5).

It is the Pythagorean theorem wearing coordinates

Drop a horizontal line from A and a vertical line to B and you have drawn a right triangle whose legs are Δx and Δy and whose hypotenuse is the distance you want, which is why the distance formula and the theorem are the same statement written two ways. The proof, the triples and solving a right triangle for a missing side all live on the Pythagorean theorem calculator. Here the theorem is a tool rather than a topic, and the diagram beside the inputs draws those two dashed legs every time so the triangle is visible rather than asserted.

Order does not matter, and distance is never negative

Swap A and B and every difference flips sign, but each one gets squared before it is added, so the total is identical. That is worth knowing because it means you can never get the subtraction the wrong way round. It also means distance is a magnitude with no direction attached: it cannot come out negative, and if it does, a minus sign has escaped from inside a bracket. Displacement, the vector version, does carry direction, and on this page the Δx and Δy rows are where that direction survives.

The third dimension costs exactly one more square

Moving into space adds a term and changes nothing else: d = √((x₂ - x₁)² + (y₂ - y₁)² + (z₂ - z₁)²). From the origin to (2, 3, 6) that is √(4 + 9 + 36) = √49 = 7. The reason it extends so cleanly is that you can apply the theorem twice. First find the run across the xy plane, √(Δx² + Δy²), then treat that run and Δz as the two legs of a second right triangle standing vertically. From (0, 0, 0) to (3, 4, 12) the ground run is 5, and 5 with 12 gives 13. The diagram in three dimensional mode draws precisely that second triangle, in the vertical slice that actually contains both points, so the picture stays honest rather than becoming a wireframe cube you have to interpret.

Why the flat formula collapses on latitude and longitude

Feed coordinates into the flat formula and you are quietly assuming that one degree of longitude is always worth the same distance as one degree of latitude. It is not. A degree of latitude is about 111 km everywhere, because meridians are all the same size. A degree of longitude is about 111 km at the equator, roughly 70 km at the latitude of London or Calgary, and exactly zero at the poles, where every meridian meets. Treat degrees as a flat grid at a high latitude and you overstate east to west distances badly. The degrees are angles, not lengths, and they have to be turned into arc length on a sphere before anything can be added up.

The haversine formula, and why not the law of cosines

The standard answer is the haversine formula, which finds the central angle between the two points and multiplies it by the radius of the Earth: a = sin²(Δφ/2) + cos φ₁ cos φ₂ sin²(Δλ/2), then d = 2R · asin(√a). There is a shorter alternative, the spherical law of cosines, and it gives the same answer in exact arithmetic. It is avoided because on real hardware it falls apart for nearby points: the cosine of a small angle sits at something like 0.99999999, and taking an inverse cosine of a number that close to one throws away most of the significant digits. Haversine is built from sines of half angles, which stay well away from that cliff. This page runs both and they agree to a millimetre on a transatlantic pair, which is the check worth having rather than the claim.

How wrong is treating the Earth as a ball?

Honestly wrong, but usefully so. This page uses the IUGG mean radius, 6,371.0088 km. The real planet bulges: 6,378.137 km at the equator against 6,356.752 km at the poles, a spread of about 21 km. Spherical trigonometry therefore carries an error of up to about 0.5 percent, with typical errors nearer 0.3 percent. That is the figure every calculator quotes and almost none converts, so here it is converted: on the 5,570 km between New York and London, half a percent is up to 28 km. For a flight plan that matters and you want an ellipsoidal method such as Vincenty, which is accurate to about half a millimetre but refuses to converge for nearly antipodal points. For working out whether to cycle or take the bus, it does not matter at all. The result panel prints the band rather than a single number pretending to be exact.

A straight line is not a driving distance

This is the single most common misreading of a geographic result. A great circle distance is the shortest path over the surface of the Earth, as the crow flies, ignoring roads, rivers, mountains, borders, one way systems and the sea. A driving distance follows a road network and is almost always longer, sometimes far longer: two points either side of an estuary can be four kilometres apart and forty by road. Road distances come out of a routing engine that knows the actual network, not out of any formula, which is why no page that gives you a formula can also give you a drive time. Use the figure here as a floor. Whatever you actually travel will be at least this far, and usually more.

The bearing is the other half of the answer

A distance on its own does not tell you which way to set off, so the panel also prints the initial bearing, in degrees clockwise from north and as a compass point. London to Paris is 343.6 km on a bearing of about 148 degrees, which is south south east. The word initial is doing real work there. On a great circle the bearing changes continuously along the route, because you are constantly cutting across meridians. Hold one fixed compass heading the whole way instead and you are sailing a rhumb line, which is easier to steer and longer: London to New York that way is about four percent further than the great circle. That gap is why long haul flight paths look bent on a flat map and are not.

Units, and the one the Earth defined

Geographic results come out in kilometres, statute miles, nautical miles and metres at once, because different trades count in different units and a bare number labelled only as miles helps nobody. A statute mile is 1,609.344 m. A nautical mile is 1,852 m, and it is the interesting one: it was defined as one minute of arc along a meridian, so one degree of latitude is sixty nautical miles by construction. On this model sphere that check returns 60.04 rather than a clean 60, and the leftover four hundredths is the flattening of the planet showing through a spherical model. Coordinate geometry results carry no unit at all, deliberately. Enter metres and you get metres, enter pixels and you get pixels.

How many decimal places do you actually need?

Coordinates arrive with wildly different precision depending on where they came from, and more digits are not automatically better. One decimal place of latitude is about 11 km, two is about 1.1 km, three is about 110 m, four is about 11 m, five is about 1.1 m and six is about 11 cm. Four places puts you on the right building, five on the right parking space. Anything past six is noise from a spreadsheet rather than information from a receiver, and it will never survive the half percent that the spherical model costs you anyway. If your coordinates came as degrees, minutes and seconds, convert with dd = d + m/60 + s/3600 and make the result negative for south and for west before you type it in.

The case every calculator gets wrong

Enter the same point twice. The answer must be zero, and it must be a real zero rather than a rounding crumb such as 1.4 times ten to the minus eleven. Naive great circle implementations return exactly that crumb, because an inverse cosine of a value that rounding has nudged just past one drifts away from the correct answer. Every mode here short circuits identical inputs to an exact zero and says so in the panel, which also means that a distance of zero is a reliable signal that you pasted the same coordinate into both fields.

Where to go next

This page owns distance between two points and nothing else: on a plane, in three dimensions, and across the surface of the Earth. For the steepness of the line joining those two points rather than its length, use the slope calculator. For the right triangle itself, its missing sides and its triples, use the Pythagorean theorem calculator. For the space a shape encloses rather than the gap between two points, start at the area calculator or the volume calculator.

FAQ

Frequently Asked Questions

Does it matter which point I call A and which I call B?

No. Swapping them flips the sign of every difference, but each difference is squared before anything is added, and squaring destroys the sign. From (5, 6) to (-7, 11) the run is -12; the other way round it is +12; both square to 144 and the distance is 13 either way. That is also why a distance can never come out negative. What does change is the initial bearing in Earth mode, which is the direction from the first point to the second, so reversing the pair reverses the heading.

How does the distance formula change in three dimensions?

It gains one more squared term and nothing else: d = √((x₂ - x₁)² + (y₂ - y₁)² + (z₂ - z₁)²). From the origin to (2, 3, 6) that is √(4 + 9 + 36) = √49 = 7. The reason it extends so neatly is that you are applying the right triangle rule twice. First find the run across the xy plane, √(Δx² + Δy²), then use that run and Δz as the legs of a second triangle standing vertically. From (0, 0, 0) to (3, 4, 12) the run is 5, and 5 with 12 gives 13.

Why does the flat distance formula give the wrong answer for latitude and longitude?

Because it assumes a degree of longitude is worth the same distance as a degree of latitude, and it is not. A degree of latitude is about 111 km anywhere on the planet. A degree of longitude is about 111 km at the equator, roughly 70 km at the latitude of London, and exactly zero at the poles where all the meridians meet. Latitude and longitude are angles, not lengths, so they have to be converted into arc length on a curved surface before they can be combined. That is the job the haversine formula does.

How far out is a haversine distance, given the Earth is not a perfect sphere?

Up to about 0.5 percent, and typically nearer 0.3 percent. The planet is 6,378.137 km in radius at the equator and 6,356.752 km at the poles, so any single radius is a compromise; this page uses the mean of 6,371.0088 km. Half a percent on the 5,570 km between New York and London is up to 28 km, which is why the result panel prints a band rather than pretending to be exact. If you need better, an ellipsoidal method such as Vincenty gets to roughly half a millimetre, at the cost of failing to converge for nearly opposite points.

Is a great circle distance the same as the distance I would drive?

No, and the gap can be large. A great circle distance is the shortest path over the surface of the Earth, ignoring roads, rivers, mountains and coastlines. A driving distance follows a real road network and is almost always longer, occasionally many times longer where a bridge, a ferry or a mountain range gets in the way. Road distances come from a routing engine that holds the network, not from a formula, so treat the figure here as a floor: whatever you travel will be at least this far.

What is the initial bearing, and why does it not stay the same along the route?

It is the compass heading you set off on, measured clockwise from north, and the panel prints it in degrees and as a compass point. London to Paris starts at about 148 degrees, south south east. It is called initial because a great circle crosses every meridian at a different angle, so the heading drifts continuously as you travel. Holding a single fixed heading instead traces a rhumb line, which is simpler to steer and longer: London to New York that way runs about four percent further than the great circle.

How do I enter a coordinate written in degrees, minutes and seconds?

Convert it to decimal degrees first with dd = d + m/60 + s/3600, then make the result negative if the hemisphere letter is S or W. So 51° 30′ 26.6″ N becomes 51 + 30/60 + 26.6/3600 = 51.5074, and 0° 7′ 40.1″ W becomes -0.1278. Some sources use degrees and decimal minutes instead, such as N 42 59.458, in which case it is simply dd = d + m/60. The Earth mode also prints point A back in degrees, minutes and seconds so you can check you converted the right way.

How many decimal places of latitude and longitude do I actually need?

Each place is worth roughly ten times less ground than the one before it. One decimal place of latitude is about 11 km, two about 1.1 km, three about 110 m, four about 11 m, five about 1.1 m and six about 11 cm. Four places lands you on the right building and five on the right parking space. Beyond six you are recording digits that no consumer receiver can justify, and in any case they vanish inside the half percent that a spherical Earth model costs you.

Why is one minute of latitude equal to one nautical mile?

Because that is how the nautical mile was defined: one minute of arc along a meridian. It makes a chart enormously easier to read, since the latitude scale up the side doubles as a distance scale. The modern nautical mile is fixed at exactly 1,852 m rather than left to follow the planet, so the match is no longer perfect. Measure one degree of latitude on the sphere this page uses and it comes back as 60.04 nautical miles rather than a clean 60, and that leftover is the flattening of the Earth showing through.