Coordinate Distance Calculator

Calculate Euclidean distance between two points in 2D or 3D. Enter coordinates in the same unit, preserve large and decimal differences, then copy or save TXT and JSON.

How to use

  1. Choose 2D or 3D.
  2. Enter both points in the same unit and calculate.
  3. Review the distance and displayed differences, then copy the result.

Calculation inputs

Point A
Point B

Enter Cartesian x/y coordinates (and z in 3D) in the same unit. Plain signed numbers, at most 64 characters, 12 fractional digits and magnitude 10^18 each. No exponents, commas, spaces or unit text. Write decimals as 0.5.

Distance is rounded to 12 decimal places, with trailing zeros removed. TXT/JSON: 4,000 bytes each. Inputs and results are neither stored nor sent.

Results

Try a use case and check the result

Calculate straight-line distance between two points in a plane or in space, using one consistent unit.

Example buttons replace the inputs and settings above and calculate. Restore previous input steps back one example at a time. After trying multiple examples, repeat restore to return to your original input. This history is lost when the page closes.

Check a 3–4–5 triangle in a plane

Input and settings

2D / A: (0,0) / B: (3,4)

Expected result

Distance: 5
B − A: (3,4)

Include a Z difference of 12

Input and settings

3D / A: (1,2,3) / B: (4,6,15)

Expected result

Distance: 13
B − A: (3,4,12)

How to read the result

Distance is the square root of the sum of squared coordinate differences: √(3²+4²)=5 in 2D and √(3²+4²+12²)=13 in 3D. JSON includes the original coordinates and differences for checking. If inputs use millimetres, the distance does too.

Scope and limits

This does not calculate geographic or route distance. Each coordinate allows at most 64 characters, 12 fractional digits and magnitude 10¹⁸. Use plain numbers in one unit, without exponents, commas or outer spaces. The square root uses integer/rational arithmetic rounded to 12 decimal places, with half ties away from zero. A browser supporting Workers is required.

Verification: existing calculate checks cover distances 5 and 13, rounding of √2 and invalid input. Examples run the calculation; restoration returns inputs and dimension, including hidden Z coordinates. The prior calculated result is not saved; calculate again if needed.

Continue with the next task

Details and limits

In 2D, distance = sqrt((Bx−Ax)^2 + (By−Ay)^2). In 3D, also add (Bz−Az)^2 before taking the square root. All axes must use the same unit, which is also the distance unit.

The example points A(0, 0) and B(3, 4) have distance 5. In 3D, A(0, 0, 0) and B(3, 4, 12) have distance 13. Swapping points does not change the distance.

Negative and decimal coordinates are allowed. Coordinate differences and squares use integer-based arithmetic, preserving small differences between large coordinates. Even near 10^18, differences of 3 and 4 still yield distance 5.

The square root is rounded to 12 decimal places using integer arithmetic, with halfway values rounded away from zero. Irrational distances are displayed/saved as rounded values. The result can exceed the coordinate input magnitude limit, but all valid point pairs are supported.

2D hides z and excludes it from calculation and exports. Switching to 3D requires z inputs. Changing dimensions clears the old result but retains coordinates. The example button switches back to 2D.

TXT includes dimensions, normalized points, signed B-minus-A differences and distance. JSON also records precision and method. Coordinates, differences and distance remain strings. Files are UTF-8 without a BOM or added trailing newline.

Editing any coordinate or dimensions cancels work and clears old output. Cancel keeps inputs. Reset clears all coordinates and results, keeping dimensions.

Frequently asked questions

How do I switch between 2D and 3D?

Use the dimensions selector. 3D requires z for both points. Hidden z values are excluded from 2D calculations and exports.

Are small differences between large coordinates preserved?

Yes. Inputs up to 10^18 in magnitude and 12 fractional digits are retained with integer-based arithmetic before subtraction.

Is a decimal distance completely exact?

An irrational square root is rounded to 12 decimal places. Differences and their squared sum are computed without rounding.

Related tools

Inputs and storage

Keep any content you need before clearing. This tool does not autosave inputs or results. Reloading or closing the page, clearing inputs or resetting may discard your work.

Favorites and language preferences are stored separately and may be lost when site data is cleared. Tool resets and site-data deletion do not delete files already downloaded to your device.

Explore tools & games

All 120 tools · 16 games

All 120 tools · 16 games

Text & writing 26

Calculators & converters 22

Date & time 12

Images & PDF 26

Data & web 28

Random & handy 6

Games 16