Home · Everyday · Geometry & Coordinates · Length of a Line Segment Calculator
Length of a Line Segment Calculator
Measures the straight-line distance between two points in the plane, and also reports the segment's midpoint and its slope.
What this calculator does
Measures the straight-line distance between two points in the plane, and also reports the segment's midpoint and its slope. Where a measure is involved, US and metric units are both accepted — flip the unit toggle and the figures convert with the same definitions the formula uses. Every result on this page is computed from the formula stated below, with no hidden rounding steps.
The formula and method
The length of a segment is the Euclidean distance between its endpoints, d = √((x₂−x₁)² + (y₂−y₁)²), a direct application of Pythagoras to the horizontal and vertical differences. The midpoint is the component-wise average of the endpoints, and the slope is rise over run, (y₂−y₁)/(x₂−x₁).
The slope output is undefined for a vertical segment (x₂ = x₁) because the run is zero; the length and midpoint remain valid in that case. All quantities share the coordinate units, so mixing units between axes gives a meaningless length.
Worked example
With the example inputs this page opens with (x₁ 0, y₁ 0, x₂ 3, y₂ 4), the result is 5.000000 — segment length. Computed from the inputs on this page with the formula below — change any figure and every result updates.
Quick reference
| x₁ | Segment length |
|---|---|
| 0 | 5.000000 |
| 1 | 4.472136 |
| 2 | 4.123106 |
| 5 | 4.472136 |
| 10 | 8.062258 |
Computed with the same formulas as the calculator above — enter any values there for figures beyond this table.
Common questions
Does the order of the two points matter?
Not for the length or midpoint — both are symmetric. The slope also stays the same, since swapping the points negates both rise and run.
How does the Length of a Line Segment Calculator work?
Measures the straight-line distance between two points in the plane, and also reports the segment's midpoint and its slope. Point (x1, y1) · Point (x2, y2) → Length. The result updates as you type, and the formula and method on this page state the exact definitions used, so you can reproduce the calculation by hand.
What inputs does the Length of a Line Segment Calculator need?
Point (x1, y1) · Point (x2, y2) → Length. Invalid entries — such as a zero denominator, an out-of-range value or a malformed list — produce a plain-language message instead of a misleading number.
Is the Length of a Line Segment Calculator free to use?
Yes. It runs entirely in your browser with no sign-up, and the same calculator is available as an embeddable widget via the Embed button, so it can be placed on another site with its calculation intact.