Slope Calculator
Enter two points and this slope calculator finds the slope of the line through them, as a decimal and as a reduced fraction. It also writes the equation in slope-intercept, point-slope and standard form, and gives the intercepts, the angle of inclination, the percent grade, the perpendicular slope, the distance between the points and the midpoint. It handles horizontal and vertical lines too.
Updated
Results
- Slope as a fractionReduced rise/run
- Line
- Point-slope formBuilt on the first point; not shown for a vertical line
- Standard formAx + By = C
- y-intercept (b)Where the line crosses the y-axis
- x-interceptWhere the line crosses the x-axis; none for a horizontal line
- Angle of inclination (°)From the positive x-axis; negative for a falling line
- Grade100 × slope
- Perpendicular slope−1 ÷ m
- Rise (Δy, units)y₂ − y₁
- Run (Δx, units)x₂ − x₁
- Distance between the points (units)
- Midpoint
Results are estimates. See the methodology below.
How to use the calculator
- Enter the first point as x₁ and y₁, and the second as x₂ and y₂. Negative numbers and decimals are fine.
- For a real-world slope, use the same unit for every coordinate. For a roof, put the run (horizontal) on the x-axis and the rise on the y-axis.
- Read the slope and the slope-intercept equation at the top, then the other forms and measurements below.
The two points must be different. When x₁ = x₂ the line is vertical: the slope, grade, y-intercept and point-slope form are not shown because they don't exist, and the equation appears as x = constant. A horizontal line has no x-intercept and no defined perpendicular slope, so those results are hidden.
Formulas used
m = (y₂ − y₁) ÷ (x₂ − x₁) = rise ÷ run
- Slope-intercept form: y = mx + b, with b = y₁ − m·x₁.
- Point-slope form: y − y₁ = m(x − x₁), built on the first point you enter.
- Standard form: Ax + By = C, reduced to the smallest whole numbers with A positive (B positive when A is 0). This works for inputs with up to 6 decimal places.
- Angle of inclination: θ = arctan(m), in degrees from the positive x-axis, between −90° and 90°. A negative angle means the line falls from left to right.
- Grade: 100 × m, written as a percentage, as on road signs and ramp plans.
- Perpendicular slope: −1 ÷ m, the negative reciprocal.
- Distance: √(Δx² + Δy²); midpoint: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2).
Equations are shown with up to 10 significant digits, so a slope of 1/12 appears as 0.08333333333 in the equation and exactly as 1/12 in the fraction.
Worked examples
1. Homework: through (2, 3) and (6, 5)
Rise 2, run 4, so m = 0.5 = 1/2. The calculator gives y = 0.5x + 2, y − 3 = 0.5(x − 2) and x − 2y = −4. The line crosses the x-axis at −4, rises at 26.565051°, and any line perpendicular to it has slope −2. The points are 4.472136 units apart with midpoint (4, 4).
2. A falling line: (−1, 4) and (3, −2)
Rise −6 over run 4 gives m = −1.5 = −3/2, the equation y = −1.5x + 2.5 or 3x + 2y = 5, and an angle of −56.309932°.
3. Roof pitch and ramp slope
Pitch is rise in inches per 12 inches of run, so enter (0, 0) and (12, rise):
| Rise over 12 run | Slope | Grade | Angle |
|---|---|---|---|
| 1 (ramp, 1:12) | 1/12 | 8.333333% | 4.763642° |
| 4 (4/12 roof) | 1/3 | 33.333333% | 18.434949° |
| 6 (6/12 roof) | 1/2 | 50% | 26.565051° |
The U.S. Access Board's guide to the ADA Standards gives 1:12 as the maximum running slope of a ramp run and limits each run to a 30-inch rise. A 20-inch rise at 1:12 needs 240 inches of run: (0, 0) to (240, 20) gives the same 1/12 slope.
4. Road grade
A road that climbs 264 feet over one mile (5,280 feet) has a slope of 1/20, a 5% grade, and an angle of only 2.862405°.
Reading the results
A positive slope rises from left to right, a negative one falls, 0 is flat and a vertical line has no slope. The larger the absolute value, the steeper the line. Grade and angle are two ways to express the same steepness, but they don't scale together: doubling the grade doesn't double the angle. For building work, follow the plans and the code that applies to your project; the calculator only does the geometry.
Frequently asked questions
How do you find the slope from two points?
Subtract the y-values and divide by the difference of the x-values in the same order: (y₂ − y₁) ÷ (x₂ − x₁). Swapping both points gives the same answer, because the signs of the top and bottom flip together.
Is a 100% grade a vertical line?
No. A 100% grade means the rise equals the run, a slope of 1, which is a 45° angle: the line from (0, 0) to (1, 1) gives exactly 45° and 100%. A vertical line would need an infinite grade.
What is an undefined slope?
When both points have the same x-value, the run is 0 and the division has no answer. The line is vertical, written as x = constant, for example x = 3 through (3, 1) and (3, 7). Its perpendicular is horizontal, with slope 0.
What is the slope of a horizontal line?
Zero. Through (1, 4) and (5, 4) the rise is 0, so m = 0 and the equation is y = 4. It never crosses the x-axis, so there's no x-intercept.
How do I convert roof pitch to degrees?
Enter (0, 0) and (12, rise) and read the angle: a 6/12 pitch is 26.565051°. The grade is the pitch as a percentage of the run, 50% in that case.
Can it find the slope of a line from its equation or from many data points?
Not directly. For an equation, pick two points on the line and enter them. A best-fit slope through scattered data needs linear regression, which this calculator doesn't do.
Sources
Results are computed in floating-point arithmetic and rounded for display. For construction and accessibility work, check the requirements that apply to your project with the local building authority.