Slope Calculator: How to Find the Gradient from Two Points
ByMuhammad Ali•Founder of KruskalCode
22:28
5 min read

Understanding the slope of a line is a fundamental skill in algebra and geometry. It tells us how steep a line is and in which direction it's heading. Whether you call it slope or gradient, this concept is key to linear equations and graphing. Our calculator makes finding it simple.
Explanation
The slope of a line represents the 'rise over run' – how much the vertical position (y) changes for every unit change in the horizontal position (x). A positive slope means the line goes up from left to right, while a negative slope means it goes down. A horizontal line has a slope of zero, and a vertical line has an undefined slope.
Formula
The formula for calculating the slope 'm' between two points (x₁, y₁) and (x₂, y₂) is: m = (y₂ - y₁) / (x₂ - x₁)
Example
Let's say you have two points: P₁ (2, 4) and P₂ (8, 16). To find the slope, substitute these values into the formula: m = (16 - 4) / (8 - 2) m = 12 / 6 m = 2 So, the slope of the line passing through (2, 4) and (8, 16) is 2.
How to use the related calculator
To use the Slope from Two Points Calculator, simply enter the x and y coordinates for your first point (X₁ and Y₁) and your second point (X₂ and Y₂). Once you've entered all four values, the calculator will instantly display the slope of the line connecting those two points. It will also tell you if the slope is undefined for vertical lines.
Try the related calculator
Open toolFAQ
What does 'rise over run' mean?
'Rise over run' is a way to remember the slope formula. 'Rise' refers to the vertical change (difference in y-coordinates), and 'run' refers to the horizontal change (difference in x-coordinates). It's a visual way to understand slope.
What if the slope is zero?
A slope of zero means the line is perfectly horizontal. The y-value does not change as the x-value changes. For example, a line connecting (1, 5) and (7, 5) would have a slope of 0.
When is a slope undefined?
A slope is undefined when the line is perfectly vertical. This happens when the x-coordinates of your two points are the same, leading to division by zero in the slope formula. For instance, a line through (3, 2) and (3, 8) has an undefined slope.
Related articles

About the author
Muhammad Ali. Muhammad Ali is a full-stack developer and founder of KruskalCode. He builds SaaS platforms and automation systems with React and Laravel, and helps teams ship fast, scalable tools.
Need a custom calculator, dashboard, or automation workflow? Reach out to KruskalCode.