Skip to content

Slope Calculator

Slope, equation and angle from two points.

Inputs

Example: Slope (m)
2

Use this calculator on your own site

Free embed

  • Two lines of HTML, unlimited views
  • Shows a small CalculateEveryday bar, with a credit link under the calculator

What each Slope input means

x₁
x₁ and y₁ are the first point. Each point's two coordinates must stay together; which point comes first does not change the slope.
x₂
x₂ and y₂ are the second point. If x₂ equals x₁ the line is vertical and the slope is undefined; if y₂ equals y₁ the line is horizontal and the slope is 0.

Slope formula

m = (y₂ − y₁) ÷ (x₂ − x₁); then b = y₁ − m·x₁ gives y = mx + b

m=y2−y1x2−x1m = \frac{y_2 - y_1}{x_2 - x_1}

Slope measures steepness: the vertical change (rise) divided by the horizontal change (run) between two points on a line, m = (y₂ − y₁) ÷ (x₂ − x₁). On a straight line it comes out the same for every pair of points, which is what makes it the line's own number. A positive slope rises to the right, a negative one falls, zero is horizontal, and a vertical line has no slope at all because its run is zero. Once m is known, putting either point into y = mx + b gives the y-intercept b, and the point-slope form y − y₁ = m(x − x₁) can be written down straight away. The angle the line makes with the x-axis is the inverse tangent of the slope, and the slope times 100 is the percent grade used for roads and ramps.

Formula last checked against OpenStax College Algebra 2e, §2.2 'Linear Equations in One Variable' (slope formula, slope-intercept and point-slope forms, horizontal, vertical, parallel and perpendicular lines); 2010 ADA Standards for Accessible Design, §405.2 (ramp slope) on 2 October 2026. Built and maintained by Suman Kumar · How we check

Slope worked example

From (2, 3) to (6, 11) the line rises 8 while running 4, so m = 8 ÷ 4 = 2. Substituting (2, 3): b = 3 − 2 × 2 = −1, giving y = 2x − 1. The line climbs at about 63.43° to the x-axis.

More Slope examples

From (−1, 4) to (3, −2): the rise is −2 − 4 = −6 and the run is 3 − (−1) = 4, so m = −6 ÷ 4 = −1.5, or −3/2 as a fraction. Then b = 4 − (−1.5)(−1) = 2.5, and the line is y = −1.5x + 2.5, falling at 56.31° below the horizontal.

A roof that rises 6 inches for every 12 inches across: m = 6 ÷ 12 = 0.5, which builders call a 6-in-12 pitch. The angle is 26.57°, and as a road grade the same slope would be 50%.

Both points at x = 4: the run is 0, so the headline reads Undefined (vertical line), and the equation is simply x = 4.

Where the Slope calculator can give the wrong answer

  • When both points share an x-coordinate the run is zero and the slope is undefined — the line is vertical and is written x = a constant, not y = mx + b.
  • When both points share a y-coordinate the slope is 0 and the equation collapses to y = a constant.
  • The slope as a fraction is only shown when all four coordinates are whole numbers; with decimals a reduced fraction would be a rounding of a rounding.
  • Swapping the two points changes the sign of both rise and run, so the slope is the same either way.

Spotted a mistake? Tell us

Slope reference table

Slope, angle, percent grade and roof pitch
Slope (rise ÷ run)Angle with the horizontalPercent gradeRoof pitch (rise in 12)
00°0%Flat
1/12 ≈ 0.08334.76°8.33%1 in 12 — the steepest ramp the ADA allows
0.2514.04°25%3 in 12
0.526.57°50%6 in 12
0.7536.87°75%9 in 12
145°100%12 in 12
263.43°200%24 in 12
Undefined90°—Vertical
Source: Angle = inverse tangent of the slope, grade = slope × 100; 2010 ADA Standards for Accessible Design, §405.2 (ramp running slope no steeper than 1:12)

Slope FAQ

No. Reversing them makes rise and run both change sign, and the signs cancel. Just keep each point's x and y together.