Beginner

Length of a Line Segment Calculator

Find the length of a line segment between any two points (x₁, y₁) and (x₂, y₂) on the coordinate plane. Also reports the midpoint and plots the segment.
x-coordinate of start point
y-coordinate of start point
x-coordinate of end point
y-coordinate of end point
Segment length
5

Straight-line distance from P₁ to P₂

Δx
3
Δy
4
Midpoint
(1.5, 2)
P₁P₂M
Step by step
  1. 1

    Δx (horizontal change)

    3 − 0 = 3
  2. 2

    Δy (vertical change)

    4 − 0 = 4
  3. 3

    Δx² + Δy²

    3² + 4² = 25
  4. 4

    d = √(Δx² + Δy²)

    √25 = 5
    Square root of the sum of squared differences — the Pythagorean theorem on coordinate changes.
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

How does this calculator work?

Segment length from (x₁,y₁) to (x₂,y₂) is d = √((x₂−x₁)²+(y₂−y₁)²) — the Pythagorean theorem on coordinate differences. The midpoint is M = ((x₁+x₂)/2, (y₁+y₂)/2). Enter all four coordinates for the instant result and a coordinate plot.

Formula
d = √((x₂ − x₁)² + (y₂ − y₁)²)
How this is calculated

The distance formula is the Pythagorean theorem applied to coordinate differences. The horizontal change Δx = x₂ − x₁ and vertical change Δy = y₂ − y₁ form the two legs of a right triangle; the line segment is the hypotenuse. Squaring and summing the legs, then taking the square root, gives d = √(Δx² + Δy²).

The midpoint is the point equidistant from both ends: M = ((x₁+x₂)/2, (y₁+y₂)/2). The plot renders both endpoints connected by the segment and marks the midpoint M so the geometry is immediately visible.

Assumptions: coordinates share the same unit of measurement and the plane is flat (Euclidean). For distance on Earth's curved surface — e.g. between GPS coordinates — the Haversine formula is required instead.

Frequently asked questions

No. Distance is symmetric: swapping P₁ and P₂ changes the signs of Δx and Δy but not their squares, so the result is identical.

Δx = Δy = 0, so d = 0. The midpoint equals either endpoint.

Yes. All real-number coordinates work, including negative values for points in the second, third, or fourth quadrant.

Also known as

length of a line segment
distance between two points calculator
distance formula calculator
segment length calculator
coordinate distance calculator
two point distance
pythagorean distance formula

APA

TG we-Calculate Editorial Team. (2026). Length of a Line Segment Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/length-of-a-line-segment-calculator

Chicago

TG we-Calculate Editorial Team. "Length of a Line Segment Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/length-of-a-line-segment-calculator.

IEEE

TG we-Calculate Editorial Team, "Length of a Line Segment Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/length-of-a-line-segment-calculator

BibTeX

@misc{wecalculate_length_of_a_line_segment_calculator, title = {Length of a Line Segment Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/length-of-a-line-segment-calculator}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?