Home / Math / Slope Calculator

Slope Calculator: Find the Slope of a Line From Two Points

Enter the coordinates of two points and get the slope (rise over run), the equation of the line through them, the y-intercept, the angle of inclination and the slope of a perpendicular line.

By Adzita Editorial Team · Updated 2026-11-03 · How we build and check our tools

The slope formula

The slope of a straight line measures how much it rises or falls for each unit you move to the right. For two points (x1, y1) and (x2, y2) the formula is:

m = (y2 − y1) ÷ (x2 − x1)

The top part is the rise and the bottom part is the run. Because a straight line has the same steepness everywhere, any two distinct points on it give the same answer. It does not matter which point you call first, as long as you subtract in the same order on the top and the bottom. Swapping both gives the same fraction with both signs flipped, so the result is unchanged.

Once the slope is known, the y-intercept comes from b = y1 − m × x1, which gives the slope-intercept form y = mx + b.

How to read the result

The angle of inclination is arctan(m), measured from the positive x-axis, so a slope of 1 is 45 degrees. The grade is simply the slope times 100, the form used for roads, ramps and railways. A grade of 8% means 8 units of rise for every 100 units of horizontal run.

Parallel and perpendicular lines

Two non-vertical lines are parallel when their slopes are equal. They are perpendicular when the product of their slopes is −1, so the perpendicular slope is the negative reciprocal −1 ÷ m. A line with slope 3 is perpendicular to one with slope −1/3. The special cases are a horizontal line, whose perpendicular is vertical with an undefined slope, and a vertical line, whose perpendicular is horizontal with slope 0.

The point-slope form y − y1 = m(x − x1) is often the quickest way to write a line when you already know one point and the slope. To find the distance between your two points as well, the result panel includes it; the distance calculator explains that formula in detail.

Common mistakes

  1. Subtracting in mixed order. Using y2 − y1 on top but x1 − x2 on the bottom flips the sign. Keep the same order in both.
  2. Dropping negative signs. Subtracting a negative coordinate adds, so 7 − (−5) is 12, not 2.
  3. Treating a vertical line as slope zero. A vertical line has an undefined slope. A horizontal line has slope zero.
  4. Different units on the axes. If x is in metres and y is in centimetres, the slope carries those mixed units. Convert first when you want a pure ratio.
  5. Reading the angle on a stretched graph. The angle here assumes both axes use the same scale. A plot with unequal scales makes lines look steeper or flatter than the computed angle.

Worked example

A line passes through (−2, 7) and (4, −5). Find its slope and equation.

Inputs

Point 1: x1-2
Point 1: y17
Point 2: x24
Point 2: y2-5

Result

Slope m = -2

Falling line (negative slope). Rise -12 over run 6.

Rise (y2 − y1)-12
Run (x2 − x1)6
Equation (y = mx + b)y = -2x + 3
y-intercept b3
x-intercept1.5
Angle of inclination-63.4349°
Grade (slope as a percentage)-200%
Slope of a perpendicular line0.5
Distance between the points13.4164

Accuracy note: Results use standard double-precision arithmetic, so very large or very small values may be rounded. Check important results by another method.

Frequently asked questions

How do I find the slope between two points?

Subtract the y values to get the rise, subtract the x values in the same order to get the run, then divide the rise by the run. For (1, 2) and (5, 10) that is 8 ÷ 4 = 2.

What does an undefined slope mean?

It means the line is vertical, so both points have the same x value and the run is zero. Division by zero is not defined, which is why the calculator reports a vertical line with equation x = a.

Can the slope be a fraction or a decimal?

Yes. Slopes are usually ratios, so values like 1/2 or 0.75 are common. The calculator shows decimals, rounded to four places, and the exact fraction is rise over run.

How is slope different from grade or gradient?

They describe the same ratio. Gradient is another word for slope, and grade is the slope written as a percentage, so a slope of 0.05 is a 5% grade.

How do I find a line perpendicular to my line?

Take the negative reciprocal of the slope. If the slope is 4 the perpendicular slope is −1/4, and if the slope is −2/3 the perpendicular slope is 3/2.

Distance CalculatorStraight-line distance between two points in 2D or 3D, with working and taxicab distance.Midpoint CalculatorMidpoint of a segment from two endpoints, or the missing endpoint from one end and the midpoint.Linear Regression CalculatorLeast-squares line of best fit with slope, intercept, correlation r, R squared and prediction.Pythagorean Theorem CalculatorFind the hypotenuse or a leg of a right triangle, with area, perimeter, angles and triple check.

References and sources

  1. Standard coordinate geometry: slope-intercept and point-slope forms of a straight line, as covered in any secondary-school algebra text.

Check primary sources for anything you rely on.