Slope Calculator
This slope calculator finds the slope of the straight line through two distinct points in a Cartesian plane. Enter (x1, y1) and (x2, y2). For (1, 2) and (3, 6), the rise is four, the run is two and the slope is two. The corresponding line is y = 2x.
Loading calculator. JavaScript is required.
Your result
The slope calculator also returns the y-intercept for a nonvertical line. A horizontal line has slope zero. A vertical line has an undefined numerical slope and is described by a constant x coordinate instead. Two identical points do not determine one line, so the form asks you to enter distinct endpoints.
On this page
How to use the slope calculator
Enter the x and y coordinates of the first point, followed by those of the second. Preserve every minus sign and keep each x value beside its matching y value. Choose two points that belong to the line you mean to describe. A pair of points always defines a straight line when the points are distinct.
Use a common coordinate system for both points. If coordinates come from a graph, read the axis labels and intervals rather than counting the drawn squares alone. A graph may use different horizontal and vertical scales. The slope calculator uses the entered coordinate values, so a visually steep line can have a small numerical slope when the display scales differ.
Slope, rise, run and y-intercept
The rise is y2 - y1, and the run is x2 - x1. When the run is nonzero, the slope is m = (y2 - y1)/(x2 - x1). It measures the change in y per one unit increase in x. Retain the signs of both coordinate differences when dividing them.
For a nonvertical line, write y = mx + b. Substitute either entered point to find b = y1 - mx1. This b is the y coordinate where the complete line crosses x = 0. That crossing may lie outside the segment between your two points. The tool describes the infinite line through the points, not just the finite segment joining them.
Three worked two-point examples
Example one uses (1, 2) and (3, 6). Rise equals 6 - 2 = 4, and run equals 3 - 1 = 2. The slope is 4/2 = 2. The y-intercept is 2 - 2 × 1 = 0, so the line equation is y = 2x. Substituting both original points confirms the equation.
Example two uses (-2, 5) and (4, -1). Rise equals negative six, and run equals six. The slope is therefore negative one. The y-intercept is 5 - (-1 × -2) = 3. The equation y = -x + 3 passes through both points and falls as x increases.
Example three uses (0, 7) and (3, 7). Both y coordinates match, so the rise is zero and the slope is zero. The y-intercept is seven, giving the horizontal line y = 7. A zero numerator is valid here because the run is three, not zero.
Vertical lines and identical points
If both x coordinates match but the y coordinates differ, the run is zero. The line is vertical and has equation x = x1. Dividing the nonzero rise by zero does not give an ordinary real slope. The slope calculator identifies this case and does not invent a finite y-intercept or a percentage grade.
When both coordinate pairs match, rise and run are both zero. Infinitely many lines pass through that one point, so one slope cannot be determined. Enter a second distinct point from the intended line. A vertical line through x = 0 coincides with the y-axis, but it still cannot be written with one finite slope in y = mx + b form.
Slope calculator precision and input limits
The slope calculator accepts zero or signed finite coordinates whose magnitudes are from 0.000000001 to 1,000,000,000. Enter decimal points without grouping commas. Blank fields and values outside the supported range are rejected. These are form limits rather than mathematical limits on the coordinates of a straight line.
Numerical calculations use ordinary browser floating-point arithmetic. When two x values are very close, a small change in their difference can noticeably change the quotient. Keep enough measurement precision to justify the result. The displayed decimal may be rounded, and an exact rational slope is better retained as the original rise divided by run when later algebra needs that exact form.
Interpret the rate before using it
If x and y measure the same physical unit, the slope is a dimensionless ratio. If they measure different things, its units are y units per x unit, such as distance per time. The numeric result does not decide which interpretation applies. Keep the axis meanings with the number you share.
This slope calculator does not fit a trend line to a collection of observations, measure a curve's tangent or verify an engineering grade. Two points from a curve describe a secant line between those points. A correlation or regression question needs additional data and a suitable statistical method. Check both original points by substituting them into the returned nonvertical line equation before relying on it.
Questions about slope calculator
What does a slope of two mean?
For each one-unit increase in x, the line rises two y units. This is a rate between coordinate changes, not a statement about the total y value at any particular x. With points (1, 2) and (3, 6), a two-unit increase in x gives a four-unit increase in y, producing slope two.
Can the slope calculator return a negative slope?
Yes. A negative slope means y decreases as x increases along the line. For (-2, 5) and (4, -1), the rise is negative six and the run is positive six, giving negative one. The sign depends on both differences. Preserve the original signs when entering coordinates and when checking the quotient manually.
Why is a horizontal line allowed but a vertical slope undefined?
A horizontal line has zero rise and nonzero run, giving a valid zero quotient. A vertical line has nonzero rise and zero run, so the slope formula would require division by zero. It is described by x equal to a constant instead. These cases describe different directions, so they should not both be labeled slope zero.
Does swapping the two points change the slope?
No. Reversing the points changes the signs of both rise and run, leaving their quotient the same. The slope and y-intercept of a nonvertical line therefore remain unchanged. The signed rise and run outputs reverse direction because they describe travel from the entered first point to the entered second point.
What happens if the two points are identical?
The slope cannot be determined from only one distinct point. Every line through that point is a possibility, and the ratio would be zero divided by zero. Enter another point from the intended line. This differs from the midpoint of coincident points, which is still well defined at the same location.
Is slope the same as an angle in degrees?
No. Slope is rise divided by run. The angle a nonvertical line makes with a horizontal axis is related to slope through trigonometry, with conventions needed for direction. This form reports slope and coordinate differences, not an angle. A slope of one corresponds to forty-five degrees only when the axes have compatible physical scales.
How do I interpret the y-intercept?
The y-intercept b in y = mx + b is the line value at x = 0. It can lie beyond the segment between the entered points. A line passing through points with positive x coordinates may cross the y-axis elsewhere. A vertical line does not have one ordinary slope-intercept equation, so the tool does not assign it a finite b.
Can I treat the slope as a percentage grade?
Only when rise and run represent compatible vertical and horizontal lengths in the required grade model. Multiplying their dimensionless ratio by one hundred then gives a percentage. Arbitrary chart coordinates may have different meanings or units. This form reports the ratio itself and does not certify a road, roof or accessibility design.
Why can nearly matching x coordinates cause a large result?
The horizontal difference is the denominator in the slope formula. A small nonzero denominator can produce a large quotient and can amplify measurement uncertainty or rounding. Recheck both x coordinates and the precision of the measurements. A very large finite slope is different from an exactly zero run, which defines a vertical line.
Does this calculate a best-fit line for many measurements?
No. It determines the line through two distinct points. A regression calculation uses a collection of observations and a stated fitting method. Selecting two convenient observations from a noisy dataset can produce a different rate from fitting all the data. Use a statistical method that matches the question when multiple measurements are involved.
What should I include when sharing the result?
Keep the two ordered coordinate pairs, the rise, run, slope and axis meanings. For a nonvertical line, include its y-intercept or equation so another person can check both points. State any physical units and rounding used. This preserves the distinction between a numerical coordinate ratio and the practical rate you intended to describe.
Sources and method notes
Method and source notes checked on 26 November 2026. The diagrams are original explanatory drawings. Read the privacy policy for other site services.