Math calculators

Distance Calculator

Updated Sep 1, 2026 By Jehan Wadia
Rate Formulas
Point 1
Point 2
x y

Distance = 5.00
Step-by-Step Solution
d = √[(x₂ − x₁)² + (y₂ − y₁)²]
d = √[(4 − 1)² + (5 − 1)²]
d = √[(3)² + (4)²]
d = √[9 + 16]
d = √25
d = 5.00
Point 1
Point 2
x y z

Distance = 5.39
Step-by-Step Solution
Origin
Destination

5,570.2
Kilometers
3,461.0
Miles
3,007.7
Nautical Miles
Calculation Details
About the calculation methods: The primary result uses Lambert's formula on the WGS-84 ellipsoid, which accounts for Earth's oblate shape and is accurate to ~10 meters over thousands of kilometers. The Haversine formula treats Earth as a perfect sphere (R = 6,371 km), which can introduce errors up to ~0.3% but is simpler and widely used.

Introduction

The Distance Calculator helps you find the distance between two points on a coordinate plane. In geometry, we use the distance formula to measure how far apart two points are. This formula comes from the Pythagorean theorem, which you may already know from working with right triangles. All you need to do is enter the x and y coordinates of two points, and this tool will calculate the exact distance between them. It works great for homework, classwork, or anytime you need a quick and accurate answer. No more solving by hand. Just plug in your numbers and get your result!

How to Use Our Distance Calculator

Enter the coordinates of two points, and this calculator will find the distance between them with a full step-by-step solution. Choose from three modes: 2D, 3D, or Geographic distance.

2D Distance Tab: Enter the X and Y coordinates for Point 1 (X₁, Y₁) and Point 2 (X₂, Y₂). The calculator uses the distance formula to find the straight-line distance between the two points on a flat plane and displays the result on a graph.

3D Distance Tab: Enter the X, Y, and Z coordinates for Point 1 (X₁, Y₁, Z₁) and Point 2 (X₂, Y₂, Z₂). The calculator finds the straight-line distance between two points in three-dimensional space and shows them on a 3D diagram.

Geographic Distance Tab: Enter the latitude and longitude of an origin and a destination to find the real-world distance between two places on Earth. You can type a city or airport name into the search bar to auto-fill the coordinates, or enter them by hand.

Decimal Degrees or DMS: In the Geographic tab, choose whether to enter coordinates as decimal degrees (e.g., 40.7128) or as degrees, minutes, and seconds (e.g., 40° 42' 46.08" N). The calculator handles both formats and keeps them in sync.

Geographic Results: The Geographic tab gives you the distance in kilometers, miles, and nautical miles. It uses Lambert's formula on the WGS-84 ellipsoid for high accuracy and also shows the Haversine result for reference, along with the difference between the two methods.

Calculate and Reset: Click the Calculate button to see your result and a full step-by-step breakdown of the math. Click Reset to return all fields to their default values.

What Is the Distance Formula?

The distance formula is a math rule that tells you how far apart two points are. It comes from the Pythagorean theorem, which says that in a right triangle, the square of the longest side (the hypotenuse) equals the sum of the squares of the other two sides. When you want to find the straight-line distance between two points, you are really finding the length of that hypotenuse.

2D Distance Formula

In two dimensions, every point has an x-coordinate and a y-coordinate. If you have Point 1 at (x₁, y₁) and Point 2 at (x₂, y₂), the distance formula is:

d = √[(x₂ − x₁)² + (y₂ − y₁)²]

You subtract the x-values to find the horizontal gap, subtract the y-values to find the vertical gap, square both gaps, add them together, and take the square root. The answer is the straight-line distance between the two points on a flat surface.

3D Distance Formula

When a third dimension is added, each point also has a z-coordinate for depth or height. The formula extends naturally by including the difference in z-values:

d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]

This works the same way as the 2D version but accounts for the extra direction. It is useful in fields like physics, engineering, and 3D modeling where objects exist in space, not just on a flat plane.

Geographic Distance on Earth

Finding the distance between two places on Earth is more complex because Earth is not flat. It is a sphere that is slightly squished at the poles (called an oblate spheroid). Two common methods handle this:

  • Haversine formula: This treats Earth as a perfect sphere with a radius of 6,371 km. It uses the latitude and longitude of two locations and applies trigonometry to find the shortest path along the surface (called a great-circle distance). It is simple and works well for most purposes, though it can be off by up to about 0.3%.
  • Lambert's formula (Vincenty's method): This uses the WGS-84 ellipsoid model, which matches Earth's true shape more closely. It accounts for the flattening at the poles and is accurate to roughly 10 meters, even over thousands of kilometers. This is the method used by GPS systems and professional surveying.

Latitude and Longitude Formats

Geographic coordinates can be written in two ways. Decimal degrees use a single number like 40.7128° for latitude. Degrees-minutes-seconds (DMS) break it into parts, such as 40° 42' 46.08" N. Both formats describe the same location. Decimal degrees are easier for calculations, while DMS is the traditional format seen on maps and in navigation.

Common Uses for Distance Calculations

Distance formulas are used every day in many areas. Students use the 2D and 3D formulas in geometry and algebra classes. Game developers use them to detect collisions and measure spacing between objects. Pilots, ship captains, and delivery companies use geographic distance to plan routes. Scientists use these formulas to track weather patterns, animal migration, and satellite orbits. No matter the scale, whether it is two dots on graph paper or two cities across an ocean, the core idea remains the same: find the straight-line gap between two known points.

Related Calculators

Two other measurements come from the same pair of coordinates: the midpoint, which is the exact center point between them, and the slope, which is the steepness of the line connecting them.


Formulas used

2D Euclidean Distance
d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}
3D Euclidean Distance
d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}
Haversine Formula (Spherical Earth)
d = 2R \arcsin\!\left(\sqrt{\sin^2\!\left(\frac{\Delta\phi}{2}\right) + \cos\phi_1 \cos\phi_2 \sin^2\!\left(\frac{\Delta\lambda}{2}\right)}\right)
Vincenty / Lambert Distance (WGS-84 Ellipsoid)
s = b \cdot A\,(\sigma - \Delta\sigma)
DMS to Decimal Degrees
D_{\text{dec}} = d + \frac{m}{60} + \frac{s}{3600}
Unit Conversions
d_{\text{mi}} = d_{\text{km}} \times 0.621371, \quad d_{\text{nmi}} = d_{\text{km}} \times 0.539957

Frequently asked questions

What is the distance between two points?

The distance between two points is the length of the straight line that connects them. In 2D, you use the formula d = √[(x₂ − x₁)² + (y₂ − y₁)²]. You subtract the coordinates, square the differences, add them, and take the square root. The result is the shortest path between the two points.

What is the difference between 2D and 3D distance?

2D distance measures how far apart two points are on a flat surface using only X and Y coordinates. 3D distance adds a Z coordinate for depth or height. The 3D formula is d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]. Use 2D for flat problems like maps or graphs, and 3D for objects in space.

What is the Haversine formula?

The Haversine formula calculates the shortest distance between two points on a sphere. It treats Earth as a perfect ball with a radius of 6,371 km. It uses latitude and longitude and applies trigonometry to find the great-circle distance. It is simple and accurate to about 0.3%.

What is Lambert's formula and why is it more accurate?

Lambert's formula (using Vincenty's method) models Earth as an oblate spheroid, a sphere that is slightly flattened at the poles. It uses the WGS-84 ellipsoid, which is the same model GPS systems use. This makes it accurate to about 10 meters, even over very long distances. That is why this calculator uses it as the primary result.

What is the difference between decimal degrees and DMS?

Decimal degrees write a location as a single number, like 40.7128°. Degrees-minutes-seconds (DMS) breaks it into parts, like 40° 42' 46.08" N. Both describe the same spot. This calculator lets you enter coordinates in either format and keeps them synced automatically.

How do I find the distance between two cities?

Go to the Geographic Distance tab. Type a city name in the search bar for the origin, then type another city name for the destination. The calculator will fill in the latitude and longitude for you. Click Calculate Distance to see the result in kilometers, miles, and nautical miles.

Can I search for airports in the Geographic tab?

Yes. The search bar recognizes many major airports by their code or name. For example, you can type "JFK," "LAX," or "Heathrow" and pick it from the list. The calculator will fill in the airport's latitude and longitude automatically.

Why are the Haversine and Lambert results slightly different?

The Haversine formula treats Earth as a perfect sphere, while Lambert's formula uses an ellipsoid that matches Earth's true shape. Earth is wider at the equator and flatter at the poles, so the sphere model introduces small errors. The difference is usually less than 0.3%, but it can add up over long distances.

Can I find the distance between a point and the origin (0, 0)?

Yes. Set Point 1 to (0, 0) and enter your other point as Point 2. The distance formula simplifies to d = √(x² + y²), which gives you the distance from any point to the origin.

What is a nautical mile?

A nautical mile is a unit of distance used in aviation and sea travel. It equals 1.852 kilometers or about 1.151 regular miles. It is based on one minute of latitude along Earth's surface, which makes it very useful for navigation.