Skip to content

Slope Calculator

Calculate the slope between two points.

x1
y1
x2
y2
Output

No result

About Slope Calculator

Slope Calculator finds the gradient of the straight line through two points, using the change in the vertical coordinate divided by the change in the horizontal one. Four coordinates go in, one number comes out, rounded to four decimal places.

The sign of the result is informative: positive means the line rises as you move right, negative means it falls, and a value of zero means the two points share the same vertical coordinate, giving a horizontal line. The magnitude is the rate of change itself — a slope of 2 means the line climbs two units for every one unit across.

A vertical line is reported explicitly rather than as an error or an infinity. When both points share a horizontal coordinate the denominator is zero, and division by zero has no finite result, so the tool states that the slope is undefined for a vertical line, which is the mathematically correct description and also the answer a student is expected to write.

Two points is the only input the page accepts, and the output is the gradient alone. The intercept is not reported, so the equation of the line is not assembled for you, and the distance between the points, their midpoint and the angle of the line to the horizontal are all absent even though they follow from the same four coordinates. No working is shown: the rise, the run and the division are not displayed, which makes the result hard to check by eye when one of the coordinates was mistyped. There is no support for three dimensions, no way to fit a line to more than two points, and no comparison of the gradient of two separate lines, so any of those means a different tool or a manual calculation.

How to use Slope Calculator

  1. 1 Enter the coordinates of the first point in the x1 and y1 fields.
  2. 2 Enter the coordinates of the second point in the x2 and y2 fields.
  3. 3 Read the slope, or the message that it is undefined for a vertical line.

Frequently asked questions

Does the order of the two points matter?

The final magnitude is the same either way, and the sign flips with the direction of travel. Most textbooks define the slope as rise over run from left to right, so entering the point with the smaller horizontal coordinate first gives the conventional reading.

What does a slope of zero mean?

The line is horizontal — both points have the same vertical coordinate, so there is no rise. It is a valid result, not an error, and it is genuinely different from an undefined slope, which is what a vertical line produces.

Can this give me the equation of the line?

Take the slope from here and substitute one of your points into the form y minus y1 equals m times x minus x1. If you need the fitted line through a whole set of points rather than exactly two, the linear regression calculator is the right tool.

Free, online, and private

Free to use

Slope Calculator is completely free. There is no account to create, no login, and no hidden charge or usage limit.

Runs online in your browser

It is a free online tool that runs entirely in your browser. Nothing to download or install — open the page and start using it right away.

Your data stays private

All processing happens locally on your device. Your input is never uploaded, stored, or tracked, so it never leaves your browser.

How Slope Calculator behaves in detail

These are the specifics of this implementation — the exact ranges, defaults and fixed settings you are working with.

Parameter Value
Formula (y2 − y1) ÷ (x2 − x1)
Vertical lines a zero horizontal difference is caught and answered with "Undefined (vertical line)" instead of a number
Precision 4 decimal places on the result
Inputs four number fields — x1, y1, x2, y2 — defaulting to 1, 2, 4 and 8, which returns 2.0000
Order sensitivity swapping both points leaves the slope unchanged, because the sign cancels between numerator and denominator

Compiled from the implementation of this tool and checked against it by itoolnet.

What Slope Calculator does not do

Knowing the edges of a tool saves more time than another list of its features. These are the cases where it will not do what you might expect.

  • The slope is the only thing produced. The y-intercept, the full equation y = mx + b and any intermediate figure are absent, so this is a two-point calculation rather than a line-fitting tool — a best-fit line through many points needs the regression page instead.
  • The vertical test is an exact comparison against zero. Two x values that differ by a floating-point residue rather than by nothing produce a very large finite slope instead of the "undefined" message, and the result looks like a steep line rather than a broken input.
  • Nothing here checks that the four values are meaningful. There is no unit, no angle in degrees, and no assumption that the points came from a straight line — coordinates taken from a curve are accepted and answered with an average gradient.

Tested and documented by itoolnet, the team that builds and maintains this site.

Share & embed this tool

Writing a guide or article? You are welcome to link to Slope Calculator with the snippet below. It is free, runs entirely in your browser, and needs no signup.