Last updated: August 1, 2026
Length of a Line Segment Calculator
Creators
Dharmendra SinghReviewers

Creators
Dharmendra SinghReviewers
Quick Answer
This calculator computes the length of a 2D line segment from its endpoint coordinates using the distance formula. It also reports the horizontal and vertical differences so you can verify each step or reuse the values in related geometry calculations.
The length of the line segment is {length}.
Creators
Dharmendra SinghReviewers

Creators
Dharmendra SinghReviewers
Formula
segment length = √((x₂ - x₁)² + (y₂ - y₁)²)
Where:
- x₁=X-coordinate of the first endpoint
- y₁=Y-coordinate of the first endpoint
- x₂=X-coordinate of the second endpoint
- y₂=Y-coordinate of the second endpoint
- d=Line segment length
Worked Examples
From (1, 2) to (4, 6)
A 3-4-5 triangle in coordinate form.
- 1Compute Δx = 4 - 1 = 3.
- 2Compute Δy = 6 - 2 = 4.
- 3Length = √(3² + 4²) = 5.
From (-3, 4) to (5, -2)
Different quadrants still use the same distance formula.
- 1Δx = 8 and Δy = -6.
- 2Square both differences to get 64 and 36.
- 3Length = √100 = 10.
From (0, 0) to (1, 1)
This produces the familiar diagonal length √2.
- 1Δx = 1 and Δy = 1.
- 2Length = √(1 + 1) = √2.
- 3Decimal value ≈ 1.414214.
From (2.5, -1.5) to (2.5, 3.5)
Vertical segments are easy because Δx becomes zero.
- 1Δx = 0.
- 2Δy = 5.
- 3Length = √(0 + 25) = 5.
Introduction
This calculator finds the length of a line segment from its two endpoints using the standard distance formula. It also reports the horizontal and vertical changes, making it easy to verify the geometry manually or use the same values in follow-up midpoint or slope calculations.
Distance formula for endpoints
A line segment in the coordinate plane can be treated as the hypotenuse of a right triangle. The horizontal leg is Δx and the vertical leg is Δy, so the Pythagorean theorem gives the segment length directly.
Δx = x2 - x1
Δy = y2 - y1
Length = √(Δx² + Δy²)
How to solve it by hand
Subtract the x-values, subtract the y-values, square both differences, add them, and then take the square root. The calculator follows exactly those steps.
Compute coordinate differences first.
Square before adding.
Take the square root only at the end.
Special cases
Horizontal segments have Δy = 0, vertical segments have Δx = 0, and identical endpoints produce a segment length of 0.
Horizontal distance reduces to |Δx|.
Vertical distance reduces to |Δy|.
Matching points collapse the segment to a single point.
Precision and rounding
The calculator rounds the reported values to six decimal places for readability while keeping exact integer results untouched.
Perfect squares remain exact integers.
Irrational results such as √2 are shown in decimal form.
Intermediate rounding is avoided.
Common mistakes
The most common mistakes are mixing up endpoint coordinates, forgetting to square a negative difference, or adding absolute changes instead of using the Euclidean formula.
Do not replace Euclidean distance with Manhattan distance.
Keep each point together as an ordered pair.
Negative Δx or Δy is fine because squaring removes the sign.
Applications
Segment length calculations appear in graphing, CAD, navigation on flat grids, physics displacement problems, and analytic geometry proofs.
Checking plotted coordinates.
Measuring design spans in technical drawings.
Supporting slope, midpoint, and circle calculations.
FAQs
Is this the same as Euclidean distance?
Yes. The length of a line segment between two planar points is exactly the Euclidean distance between them.
Can the endpoints have negative coordinates?
Yes. Negative coordinates are fully supported because the formula works with any real x and y values.
What happens when both endpoints are identical?
The segment length becomes 0 because both Δx and Δy are zero.
Why does a negative Δy not cause a negative distance?
Distance is a magnitude. Squaring the coordinate differences removes the sign before the square root is taken.
How many decimals are shown?
Results are rounded to six decimal places, which is enough for most classroom and planning tasks.
How is this different from Manhattan distance?
Line-segment length measures straight-line distance, while Manhattan distance adds the absolute horizontal and vertical travel.