Distance Calculator

Calculate distances in 2D, 3D, and on Earth (latitude/longitude). Free online calculator with step-by-step solutions and canvas visualization.

2D Coordinates2D Euclidean
Results2D Euclidean
Click "Calculate" to see the detailed steps.
🔒 100% client-side — nothing leaves your browser
Live results — no page reloads
💚 Free, no signup, no limits

Recent Calculations

No calculations yet — your last 6 will show up here.

Distance Calculator

This free online distance calculator computes the distance between two points in 2D Cartesian space, 3D Cartesian space, and on Earth using geographic coordinates. All calculations run entirely in your browser with no signup, no ads, and no server uploads.

Euclidean Distance (2D & 3D) Euclidean distance is the most intuitive notion of distance — the straight line connecting two points. In a 2D plane with coordinates $(x_1, y_1)$ and $(x_2, y_2)$, the Euclidean distance is:

$$d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$$

This formula is a direct application of the Pythagorean theorem. For 3D space with coordinates $(x_1, y_1, z_1)$ and $(x_2, y_2, z_2)$, the distance extends naturally:

$$d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}$$

The slope of the line in 2D is given by $m = \frac{y_2 - y_1}{x_2 - x_1}$, and the angle from the horizontal is $\theta = \arctan(m)$.

Great-Circle Distance (Haversine Formula) For points on Earth expressed in latitude and longitude, the Haversine formula computes the shortest distance along the Earth's spherical surface (the great-circle distance):

$$d = 2R \cdot \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)$$

where $R = 6371$ km is the mean Earth radius, $\phi$ is latitude, $\lambda$ is longitude, $\Delta\phi = \phi_2 - \phi_1$, and $\Delta\lambda = \lambda_2 - \lambda_1$.

Lambert's Ellipsoidal Formula For improved accuracy, Lambert's formula accounts for the Earth's oblateness (the equatorial radius is about 21 km larger than the polar radius). Using the WGS-84 ellipsoid parameters:

$$d \approx R \cdot \sqrt{(\Delta\phi)^2 + (\cos\phi_m \cdot \Delta\lambda)^2}$$

where $\phi_m = (\phi_1 + \phi_2) / 2$ is the mean latitude. The Lambert formula typically agrees with more rigorous geodetic calculations to within 0.1%.

Earth Parameters - Mean radius: $R = 6371$ km - Equatorial radius: $a = 6378.137$ km (WGS-84) - Polar radius: $b = 6356.752$ km (WGS-84) - Flattening: $f = (a - b) / a \approx 1/298.257$
Applications - Navigation and GPS route planning - Geographic information systems (GIS) - Aviation and maritime navigation - Physics and engineering simulations - Computer graphics and game development - Surveying and cartography
Privacy & Performance All calculations run locally in your browser using JavaScript. No data is transmitted, logged, or stored on any server. Results appear instantly with no page reloads. Your coordinate data remains private on your device.
🔒 Client-side only⚡ Web Worker processing🌐 Works offline🛡️ Zero server logs

Frequently Asked Questions

Got questions about distance calculation, coordinate systems, or how to use this tool? We've got answers.

What is Euclidean distance?

Euclidean distance is the straight-line distance between two points in Euclidean space. In 2D, it's $d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$. In 3D, it's $d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}$. It is derived from the Pythagorean theorem.

How does the Haversine formula work?

The Haversine formula calculates the great-circle distance between two points on a sphere given their latitudes and longitudes: $d = 2R \cdot \arcsin(\sqrt{\sin^2(\Delta\phi/2) + \cos\phi_1 \cos\phi_2 \sin^2(\Delta\lambda/2)})$, where $R$ is the Earth's radius (6371 km), $\Delta\phi$ is the latitude difference, and $\Delta\lambda$ is the longitude difference.

What is the difference between Euclidean and great-circle distance?

Euclidean distance assumes flat space and gives the straight-line distance through the Earth. Great-circle distance follows the Earth's curved surface. For short distances they are similar, but for long distances (e.g., New York to London), the great-circle distance is the correct travel distance along the Earth's surface.

How accurate is the Haversine formula?

The Haversine formula is accurate for most practical purposes with errors typically under 0.5%. For higher accuracy, Lambert's ellipsoidal formula accounts for Earth's oblateness (the WGS-84 ellipsoid), which can improve accuracy by up to 0.1% for long distances.

What coordinate format should I use?

You can use Decimal Degrees (e.g., 48.8566) or Degrees-Minutes-Seconds (DMS, e.g., 48° 51' 24"). For DMS, South latitudes and West longitudes should use the Southern/Western hemisphere toggle. Latitude ranges from -90° to 90°, longitude from -180° to 180°.

What is the Lambert ellipsoidal formula?

Lambert's formula approximates the distance on an ellipsoid (more accurate Earth shape) as $d \approx R \cdot \sqrt{(\Delta\phi)^2 + (\cos\phi_m \cdot \Delta\lambda)^2}$, where $\phi_m$ is the mean latitude. It accounts for Earth's flattening and is more accurate than the spherical Haversine formula.

Is this calculator private?

Yes. All calculations run locally in your browser. No data is transmitted, logged, or stored on any server. Your coordinates never leave your device.