Slope Calculator
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. Identify coordinates. x₁ = 1, y₁ = 2, x₂ = 3, y₂ = 6.
- 2. Compute the rise (Δy). y₂ − y₁ = 6 − (2) = 4.
- 3. Compute the run (Δx). x₂ − x₁ = 3 − (1) = 2.
- 4. Divide rise by run. m = 4 / 2 = 2.
- 5. Convert formats. Angle is arctan(2) = 63.4349°. Grade is 2 × 100 = 200%. Ratio is 2 : 1.
m =
2
Line rises from left to right
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.
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₂):
- Identify the coordinates: Let the first point be (x₁, y₁) and the second point be (x₂, y₂).
- Calculate the Rise: Subtract the first y-coordinate from the second y-coordinate:
Rise = y₂ − y₁. - Calculate the Run: Subtract the first x-coordinate from the second x-coordinate in the exact same order:
Run = x₂ − x₁. - 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.
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 Slope | Angle (Degrees) | Percent Grade |
|---|---|---|---|
| 1:20 | 0.05 | 2.9° | 5% |
| 1:12 (maximum slope for ADA-compliant ramps) | 0.0833 | 4.8° | 8.33% |
| 1:10 | 0.1 | 5.7° | 10% |
| 1:8 | 0.125 | 7.1° | 12.5% |
| 1:6 | 0.1667 | 9.5° | 16.67% |
| 1:4 | 0.25 | 14.0° | 25% |
| 1:2 | 0.5 | 26.6° | 50% |
| 1:1 | 1.0 | 45.0° | 100% |
| 2:1 | 2.0 | 63.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:
- Slope Intercept Form Calculator for the equation of a line in y = mx + b format, and the only page here that will rearrange a standard-form equation, Ax + By = C, into it. Stay on this page when the slope itself is the answer you want, or when you need the angle, the grade, or a missing coordinate recovered from a known slope.
- Point Slope Form Calculator to write linear equations from a point and a slope.
- Slope Formula for the deep-dive guide on rise-over-run calculations.
- Point-Slope Formula for the guide on writing linear equations using slope.
- Distance Formula Calculator to calculate the straight-line distance between two points.
- Midpoint Formula Calculator to find the exact middle coordinate of a line segment.
- y = mx + b Calculator to plot and graph linear equation intercepts.
- System of Equations Calculator to solve systems of multiple intersecting lines.
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.
Related Calculators
More tools from Education



