Skip to main content

Slope Calculator

Blake Boege
Written by Blake Boege · Founder, Calculator Answers

A slope calculator is a coordinate geometry utility that computes the slope or gradient of a straight line passing through two specified points. It operates by dividing the vertical change, known as the rise, by the horizontal change, known as the run. The same relationship can be run backwards, so the calculator also solves for a missing x or y coordinate when the slope and the other three coordinates are known. It identifies positive, negative, zero, and vertical undefined slopes, and reports two identical points as not determined rather than as a line. Educators, students, and civil engineers employ this tool to understand linear equations, design accessibility ramps, and analyze structural grades.

Enter two points and we compute the slope of the line through them. The result shows the rise, the run, the slope value, and the line type, with a step-by-step breakdown that uses your numbers.

Quick Answer

Find the slope of a line passing through two coordinate points, or switch the Solve for control and recover a missing coordinate from a known slope. Enter the values to calculate the gradient, rise, and run.

Solve for

Known Values

Enter Point 1 and Point 2 coordinates to compute slope.

Step by step

  1. 1. Identify coordinates. x₁ = 1, y₁ = 2, x₂ = 3, y₂ = 6.
  2. 2. Compute the rise (Δy). y₂ − y₁ = 6 − (2) = 4.
  3. 3. Compute the run (Δx). x₂ − x₁ = 3 − (1) = 2.
  4. 4. Divide rise by run. m = 4 / 2 = 2.
  5. 5. Convert formats. Angle is arctan(2) = 63.4349°. Grade is 2 × 100 = 200%. Ratio is 2 : 1.
Slope (positive)

m =

2

Line rises from left to right

Point 1(1, 2)
Point 2(3, 6)
Rise (y₂ − y₁)4
Run (x₂ − x₁)2
Decimal Slope (m)2
Angle (degrees)63.4349°
Percentage (%)200%
Ratio (rise:run)2 : 1
Slope-Intercepty = 2x
Point-Slopey − 2 = 2(x − 1)

Slope describes the steepness and direction of a line. This calculator determines the decimal slope, angle of inclination, slope percentage (grade), rise-to-run ratio, and linear equations in both slope-intercept (y = mx + b) and point-slope forms.

Was this helpful?

Examples

(1, 2) and (3, 6)

m = 2 (positive)

(1, 5) and (3, 1)

m = −2 (negative)

(1, 5) and (4, 5)

m = 0 (horizontal)

(3, 1) and (3, 5)

m = undefined (vertical)

How it works

Formula · m = (y₂ − y₁) / (x₂ − x₁) · angle = arctan(m) × 180 ÷ π · grade % = m × 100

For any two points (x₁, y₁) and (x₂, y₂) on a coordinate plane, the slope of the line through them is:

Slope · m = (y₂ − y₁) / (x₂ − x₁)

The numerator y₂ − y₁ is the rise (the vertical change). The denominator x₂ − x₁ is the run (the horizontal change). When the run is zero, the slope is undefined and the line is vertical. For the related calculations on the same two points, see the distance formula calculator for the line's length and the midpoint formula calculator for its center.

How to calculate the slope of a line

Slope measures the steepness and direction of a straight line on a coordinate plane. It is calculated as the ratio of vertical change (rise) to horizontal change (run) between any two points on the line.

To find the slope (often represented by the variable m) between two coordinate points (x₁, y₁) and (x₂, y₂):

  1. Identify the coordinates: Let the first point be (x₁, y₁) and the second point be (x₂, y₂).
  2. Calculate the Rise: Subtract the first y-coordinate from the second y-coordinate: Rise = y₂ − y₁.
  3. Calculate the Run: Subtract the first x-coordinate from the second x-coordinate in the exact same order: Run = x₂ − x₁.
  4. Divide Rise by Run: Divide the rise by the run to get the slope: m = Rise ÷ Run.

Rise and run on the coordinate plane

The formula is easier to hold onto as a picture. Going from the first point to the second, the run is how far you travel sideways and the rise is how far you travel up. The slope is the second divided by the first, which is why a steeper line has a larger slope and a line that falls has a negative one.

xy01326(1, 2)(3, 6)run = 2rise = 4m = rise ÷ run = 4 ÷ 2 = 2

The diagram shows a coordinate plane with the x-axis and y-axis drawn, and a straight line passing through two marked points, (1, 2) and (3, 6). A dashed horizontal leg joins the first point across to below the second and is labelled run = 2, because x goes from 1 to 3. A dashed vertical leg then rises to the second point and is labelled rise = 4, because y goes from 2 to 6. The slope is the rise divided by the run, 4 divided by 2, which is 2.

rise = y₂ − y₁ = 4
Vertical change
run = x₂ − x₁ = 2
Horizontal change
m = 4 ÷ 2 = 2
Rise over run

Working it out by hand

Let's find the slope of the line passing through the points A(2, -3) and B(5, 3).

Step 1: Assign coordinates

  • Point 1: x₁ = 2, y₁ = -3
  • Point 2: x₂ = 5, y₂ = 3

Step 2: Subtract y-coordinates (Rise)

Rise = y₂ − y₁ = 3 − (−3) = 3 + 3 = 6

Step 3: Subtract x-coordinates (Run)

Run = x₂ − x₁ = 5 − 2 = 3

Step 4: Divide Rise by Run

m = Rise ÷ Run = 6 ÷ 3 = 2

Result

The slope is 2. This is a positive slope, meaning the line rises from left to right.

Enter those two points and the panel fills in the rest from the same numbers: an angle of 63.4349°, a grade of 200%, a ratio of 2 : 1, the slope-intercept form y = 2x − 7, and the point-slope form y + 3 = 2(x − 2).

A line that falls

Nothing changes except a sign. Through (1, 5) and (3, 1) the rise is 1 − 5 = −4 and the run is 3 − 1 = 2, so m = −4 ÷ 2 = −2. The negative result is not an error state; it is the direction. As x increases by 1, y drops by 2, and the panel describes it as a line that falls from left to right.

A line that goes straight up

Through (3, 1) and (3, 5) the rise is 4 but the run is 3 − 3 = 0. The division cannot be carried out, so there is no step 4. The calculator checks for a zero run before it divides, which is why the panel reads undefined rather than Infinity. It still reports what the line does have: an angle of 90°, a ratio of 1 : 0, and the equation x = 3.

Solving for a missing coordinate

The Solve for control runs the same formula backwards. Rearranging m = (y₂ − y₁) / (x₂ − x₁) for y₂ gives y₂ = y₁ + m(x₂ − x₁). With x₁ = 1, y₁ = 2, x₂ = 6 and m = 3, the run is 6 − 1 = 5, so y₂ = 2 + 3 × 5 = 17. The panel reports y2 = 17 and notes that it used a slope of 3. The other three coordinates work the same way.

Understanding the four types of slope

  • Positive Slope (m > 0): The line rises from left to right. As x increases, y increases.
  • Negative Slope (m < 0): The line falls from left to right. As x increases, y decreases.
  • Zero Slope (m = 0): The line is completely flat and horizontal. The y-values do not change (y₂ = y₁, so the rise is 0).
  • Undefined Slope (Vertical): The line is completely vertical. The x-values do not change (x₂ = x₁, so the run is 0). Since you cannot divide by zero, the slope is mathematically undefined.

Slope equation forms

Slope is a fundamental component in describing linear equations. To see how these equations are derived from the basic coordinates, read the detailed guide on the slope formula. The two most common linear equation forms are:

  • Slope-Intercept Form: y = mx + b, where m is the slope and b is the y-intercept (the point where the line crosses the y-axis).
  • Point-Slope Form: y − y₁ = m(x − x₁), which allows you to write the equation of a line using its slope m and any single point (x₁, y₁) on that line.

Converting slope to degrees and percentage

Slope can be represented in multiple mathematical formats depending on the context:

  • Slope Angle (Degrees): To find the inclination angle (θ) of a line in degrees, take the inverse tangent (arctangent) of the slope (m) and convert radians to degrees:
    Angle = arctan(m) × (180 ÷ π). For example, a slope of 1 yields an angle of 45°, while a vertical line has a 90° angle.
  • Slope Percentage (Grade): Often used in construction and geography to define inclination. To find the percentage, multiply the slope by 100:
    Grade (%) = (Rise ÷ Run) × 100. For example, a slope of 0.1 represents a 10% grade.
  • Ratio (Rise:Run): Expresses how many vertical units of rise occur for every horizontal unit of run. For example, a slope of 0.25 represents a 1:4 ratio (1 unit of rise for every 4 units of run).

Slope conversion reference table

This reference table shows conversions between rise-to-run ratios, decimal slope, angle of inclination (degrees), and percent grade.

Ratio (Rise:Run)Decimal SlopeAngle (Degrees)Percent Grade
1:200.052.9°5%
1:12 (maximum slope for ADA-compliant ramps)0.08334.8°8.33%
1:100.15.7°10%
1:80.1257.1°12.5%
1:60.16679.5°16.67%
1:40.2514.0°25%
1:20.526.6°50%
1:11.045.0°100%
2:12.063.4°200%

Real-world applications of slope

Slope is a fundamental measurement used across engineering, architecture, and construction:

  • Road Grade: Expressed as a percentage. A 6% road grade means the road rises 6 feet vertically for every 100 horizontal feet traveled.
  • Wheelchair Ramps (ADA Standards): The Americans with Disabilities Act (ADA) mandates a maximum slope of 1:12 for public ramps. This means for every 1 inch of vertical rise, the ramp must have at least 12 inches of horizontal run (approximately an 8.33% slope or 4.76° angle).
  • Roof Pitch: Roofers describe pitch as a ratio of vertical rise over a 12-inch horizontal run (e.g., a "4:12 pitch" rises 4 inches for every 12 inches of run, representing a slope of 1/3).
  • Land Drainage: Soil and pipes must have a minimum slope (typically 1% to 2%, or 1/8 to 1/4 inch of drop per linear foot) to ensure proper gravity-assisted water flow and prevent pooling.

Edge cases

  • A vertical line, and why the panel never shows Infinity. When the two x-coordinates match, the run is 0. The calculator tests for that before it divides, so the division never happens and the slope row reads the word undefined. Dividing by zero in JavaScript would produce Infinity, which is a value rather than an absence of one, and it would be the wrong answer. The line itself is real, so the panel still reports its 90° angle, its 1 : 0 ratio, and its equation.
  • A horizontal line gives 0, which is a number. Here the rise is 0 and the run is not, so 0 divided by a non-zero number is 0. Zero and undefined are opposite cases, and mixing them up is the most common slope mistake there is.
  • Both points identical. The rise and run are both 0, so the formula gives 0 ÷ 0. The calculator reports the slope as not determined and withholds the angle, the ratio and the equation rather than inventing them, because a single repeated point does not fix a line.
  • A negative slope is a direction, not a failure. The sign says which way the line tilts. Swapping which point you call first flips the sign of both the rise and the run, so the slope comes out the same; subtracting in inconsistent orders is what flips it wrongly.
  • Empty and non-numeric fields. An empty field is treated as missing rather than as zero, so the panel waits instead of reporting a slope you did not ask for. Text that is not a number produces a message naming the fields that need valid values.
  • Two solve-for combinations have no answer. Solving for x₁ or x₂ with a slope of 0 is impossible, because a horizontal line passes through every x. Solving for y₁ or y₂ when the two x-coordinates are equal is impossible for the mirror reason. The calculator says so instead of returning a number.
  • Fractions have to be entered as decimals. The fields read numbers, not expressions, so 1/2 is rejected with a message rather than read as 0.5. Type 0.5.
  • The vertical line's ratio is normalised. A vertical line always shows a ratio of 1 : 0 whatever its rise, because with a run of zero the only information the ratio carries is that the run is zero. The 1 is a placeholder for any rise, not a reading of yours.
  • Displayed values are rounded to four decimal places. The arithmetic runs at full precision and rounds only on the way to the screen, so an angle shown as 63.4349° is a rounded reading of a longer number. The same applies inside the equation rows: a slope of one third is written as 0.3333x, which is the rounded decimal rather than an exact coefficient.

Common mistakes when calculating slope

  • Subtracting coordinates in inconsistent orders: Doing (y₂ − y₁) / (x₁ − x₂) will flip the sign of the slope. Always subtract both coordinates starting with the same point: (y₂ − y₁) / (x₂ − x₁) or (y₁ − y₂) / (x₁ − x₂).
  • Inverting the formula (Run over Rise): Writing the slope as Δx / Δy instead of Δy / Δx. Always remember that slope is "rise over run" (y values on top, x values on bottom).
  • Sign errors with negative coordinates: Forgetting that subtracting a negative number yields addition (e.g., 3 − (−5) = 3 + 5 = 8).
  • Assuming vertical lines have zero slope: Horizontal lines have a slope of zero, whereas vertical lines have an undefined slope.
  • Calling an undefined slope infinite: A vertical line has no slope value at all. Infinity is not what the division returns; the division is simply not defined.

Your coordinates stay in the page

The coordinates and slope you enter are processed by this page in your browser. They are not sent to a server, not stored after you close the tab, and not visible to anyone else. There is no account and nothing to sign up for.

Related coordinate geometry tools

Once you find the slope of a line, explore other characteristics of your line segment or equations:

Sources

  • The ramp figure this page quotes: ADA Standards for Accessible Design, section 405.2, which gives a maximum running slope of 1:12 for ramps. Verified 2026-08-18.
  • The slope formula itself carries no citation, and deliberately so. m = (y₂ − y₁) / (x₂ − x₁) is the definition of slope rather than a finding about the world, so there is nothing to attribute. The angle, grade and ratio rows are algebraic restatements of the same quantity.

Frequently asked questions

The slope formula is m = (y₂ − y₁) / (x₂ − x₁). Subtract the y-coordinates to get the rise, subtract the x-coordinates to get the run, then divide the rise by the run.

Pick any two points on the line. Subtract the first y-coordinate from the second y-coordinate to calculate the rise. Subtract the first x-coordinate from the second x-coordinate to calculate the run. Divide the rise by the run (rise ÷ run).

Slope describes how steep a line is and its direction. A positive slope rises from left to right; a negative slope falls. A slope of zero indicates a completely horizontal line, while a vertical line has an undefined slope.

When two points have the same x-coordinate but different y-coordinates, the run (x₂ − x₁) is 0 while the rise is not. Dividing a non-zero rise by zero is mathematically undefined, so vertical lines are said to have an undefined slope.

They are opposite situations that are easy to swap by mistake. A slope of zero is a real number: the rise is 0, the run is not, and 0 divided by a non-zero number is 0. The line is horizontal. An undefined slope is not a number at all: the run is 0, so the division cannot be performed. The line is vertical. The calculator keeps them visibly apart, showing 0 for the horizontal case and the word undefined for the vertical one, and it never prints Infinity for either.

The calculator reports that the slope is not determined, and does not show an angle, a grade, a ratio, or an equation. Both the rise and the run come out as zero, so the formula gives 0 ÷ 0, which is undefined. The geometry is the clearer way to see it: because the two points are identical, they do not determine a unique line. Infinitely many lines pass through that one point, so there is no single slope to report. This is a different situation from a vertical line, where two different points share an x-coordinate. That is one specific line, and it has a genuine 90 degree inclination; what it lacks is a finite slope value, which is why its slope is called undefined.

A slope of zero means the line is completely horizontal. The two points have the same y-coordinate, so there is no vertical change (rise = 0).

Yes. A negative slope means the line tilts downwards from left to right. As you move from left to right, the y-value decreases.

Yes to both. The coordinate fields take integers and decimals, positive or negative, so −2.5 is a valid coordinate. Fractions typed with a slash are not read: entering 1/2 returns a message asking for valid numbers rather than treating it as 0.5. Convert a fraction to its decimal form first. The calculator then reports the slope, the rise, and the run step by step.

No. This page works from coordinates rather than from an equation, so it will not read y = 2x + 3 and extract the 2 for you. In slope-intercept form the slope is already the coefficient of x, so you can read it straight off. If you want the equation built for you instead, the slope intercept form calculator and the y = mx + b calculator both take that route. What this page does do is work in reverse: give it a slope and three of the four coordinates and it solves for the fourth.

Yes, and it is the least obvious thing the tool does. The Solve for control at the top switches between finding m and finding x₁, y₁, x₂, or y₂. Pick a coordinate, enter the other three plus the slope, and it rearranges m = (y₂ − y₁) / (x₂ − x₁) for the one you left out. Two combinations have no answer and say so rather than guessing: solving for x₁ or x₂ when the slope is 0, because a horizontal line fixes no x, and solving for y₁ or y₂ when the two x-coordinates are equal, because the run is 0.

Parallel lines have equal slopes, so a line parallel to one with slope 3 also has slope 3. A perpendicular line has the negative reciprocal: if a line has a slope of 3, the perpendicular line has a slope of −1/3, and if the slope is −2/5, the perpendicular slope is 5/2. This calculator does not compute either for you. Find the slope here first, then flip and negate it yourself for the perpendicular case.

ADA-compliant wheelchair ramps must have a maximum slope of 1:12, which is approximately a 4.8° angle of inclination or an 8.33% grade. This means that for every 1 inch of vertical rise, the ramp must have at least 12 inches of horizontal run to ensure accessibility.

To convert a slope to degrees, take the inverse tangent (arctan) of the decimal slope value and convert the resulting radians to degrees by multiplying by 180 and dividing by pi. For example, a slope of 1.0 has an angle of arctan(1.0) = 45°.

A 2% slope is equal to exactly 0.24 inches per foot, which is commonly rounded to 1/4 inch per foot in construction and drainage applications. This represents a drop of 1/4 inch vertically for every 12 inches horizontally.

Yes. It is free to use with no account, no sign-up, and no limit on calculations. Everything runs inside this page in your browser.