Slope calculator

Enter two points to get the slope and the line through them.

Tier 0 · browser · unlimited

Two points

Slope (m)
3
Equation of the liney = 3x − 1
y-intercept (b)-1
Distance between points6.3245553203
Angle of inclination (°)71.5651
Midpoint(2, 5)

Rise over run

The slope of a line says how much y changes for each step in x: m = (y₂ − y₁) ÷ (x₂ − x₁), "rise over run". A positive slope climbs to the right, a negative one falls, zero is horizontal, and a vertical line has no defined slope.

Once you have the slope, the line's equation follows: y = mx + b, where b is where the line crosses the y-axis.

Worked example

Points (1, 2) and (3, 8): m = (8 − 2) ÷ (3 − 1) = 6 ÷ 2 = 3. Then b = 2 − 3 × 1 = −1, so the line is y = 3x − 1. The points are √(2² + 6²) ≈ 6.32 apart, the line rises at about 71.6°, and the midpoint is (2, 5).

Slope as a grade

Road and roof slopes are often given as percentages: a slope of 0.08 is an 8% grade, rising 8 m every 100 m.

How this works

The page subtracts the coordinates to get the rise and the run and divides them for the slope. It solves for the y-intercept with b = y₁ − m·x₁ and writes the equation y = mx + b. The distance between the points comes from the Pythagorean theorem, the angle from the arctangent of the slope, and the midpoint from the averages of the coordinates. When x₁ = x₂ the line is vertical: the slope is undefined and the equation is x = constant. Everything runs in your browser.

Frequently asked

What does a slope of 0 mean?

A horizontal line: y does not change as x changes.

Why is the slope of a vertical line undefined?

The run is zero, and division by zero has no value.

How do I turn a slope into a percentage grade?

Multiply by 100: a slope of 0.05 is a 5% grade.

How do I find the y-intercept?

Plug one point into y = mx + b and solve for b.

Sources

Reviewed Oct 17, 2026 · test vectors fixtures/calculators/math/slope-calculator/