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.

Your figures

Example result — edit the figures to make it yours

5

Segment length

Computed from the inputs on this page with the formula below — change any figure and every result updates.

Midpoint x1.500000
Midpoint y2.000000
Slope1.333333

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

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

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

Quick reference — varying x₁
x₁Segment length
05.000000
14.472136
24.123106
54.472136
108.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.