Slope Calculator

Slope between two points, with distance, midpoint, angle, line equation and percent grade.

Slope (m)

2

Slope = rise ÷ run = 6 ÷ 3.

Rise (y₂ − y₁)
6
Run (x₂ − x₁)
3
Distance between the points
6.708204
Midpoint
(2.5, 5)
Angle with the x-axis
63.434949°
Equation of the line
y = 2x + 0
Perpendicular slope
-0.5
Percent grade
200%

The slope of the line through (1, 2) and (4, 8) is 2.

Add this calculator to your website

Free to use on any site or blog. Paste this code where you want the calculator to appear. It stays up to date, needs no account, and keeps your visitors' numbers in their own browser.

Preview

How it works

Enter two points, (x₁, y₁) and (x₂, y₂). The slope is how much the line rises for each step across: the change in y divided by the change in x. A positive slope goes up to the right, a negative slope goes down, and a slope of 0 is a flat line. If both x values are the same the line is vertical and the slope is undefined.

The tool also gives the straight-line distance between the points (the distance formula, which is the Pythagorean theorem), the midpoint (the average of the coordinates), the angle the line makes with the x-axis, and the equation of the line in slope-intercept form, y = mx + b.

The percent grade is the slope as a percentage, used for roads, ramps and roofs. A slope of 0.08 is an 8% grade.

Check it by hand: for the points (1, 2) and (4, 8), the rise is 8 − 2 = 6 and the run is 4 − 1 = 3, so the slope is 6 ÷ 3 = 2. The distance is √(3² + 6²) = √45 = 6.708. The midpoint is ((1 + 4) ÷ 2, (2 + 8) ÷ 2) = (2.5, 5). The angle is arctan(2) = 63.43°, and b = 2 − 2 × 1 = 0, so the line is y = 2x.

Slope m = (y₂ − y₁) ÷ (x₂ − x₁)
Distance = √((x₂ − x₁)² + (y₂ − y₁)²)
Midpoint = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2)
Line: y = mx + b, with b = y₁ − m × x₁

Worked example

Points (1, 2) and (4, 8). Rise = 8 − 2 = 6 and run = 4 − 1 = 3, so the slope is 6 ÷ 3 = 2. The line is y = 2x + 0, since b = 2 − 2 × 1 = 0.

The distance is √(3² + 6²) = √45 = 6.7082. The midpoint is (2.5, 5). The angle with the x-axis is atan(2) = 63.4349°, and the perpendicular slope is −0.5.

Good to know

  • Works with two points. It does not fit a line through many points (regression).
  • The angle is measured from the x-axis, between −90° and 90°. A vertical line is shown as 90°.
  • Results are rounded to 6 decimal places for display.

Questions people ask

How do I find the slope between two points?

Divide the change in y by the change in x: m = (y₂ − y₁) ÷ (x₂ − x₁). For (1, 2) and (4, 8), m = 6 ÷ 3 = 2.

What is the distance formula?

Distance = √((x₂ − x₁)² + (y₂ − y₁)²). It is the Pythagorean theorem applied to the change in x and the change in y.

How do I find the midpoint of two points?

Average the x values and average the y values. The midpoint of (1, 2) and (4, 8) is (2.5, 5).

What is the slope of a vertical line?

It is undefined, because the run is 0 and you cannot divide by 0. A horizontal line has a slope of 0.

How do I turn a slope into a percent grade?

Multiply the slope by 100. A slope of 0.08 is an 8% grade, which rises 8 units for every 100 units across.

What is the slope of the line through (0, 0) and (4, 2)?

The rise is 2 and the run is 4, so the slope is 2 ÷ 4 = 0.5, which is a 50% grade.

Part of the guide: Math and study calculators: percentages, fractions, GPA and everyday sums

Formulas and text last checked on 14 October 2026. Everything is calculated in your browser, so nothing you enter is sent or stored. Spotted a mistake? Tell us and we will fix it.