Online Tool Store Online Tool Store

Slope Calculator

Enter two points to get the slope, y-intercept, line equation, angle, distance, and midpoint, with vertical lines handled properly. Runs in your browser.

🔒 This tool runs entirely in your browser. Your files are never uploaded to a server.

Equation of the line

Point 1
Point 2

Example shown — enter your own coordinates.

Slope (m)
Y-intercept (b)
Angle from horizontal
Distance between points
Midpoint
Rise / run

How it works

  1. Enter the coordinates of two points on the line.
  2. Everything updates as you type: slope, intercept, equation, angle, distance, and midpoint.
  3. Read the plain-English summary if you want a sanity check on direction and steepness.
  4. Copy the whole set of results in one go.

The formulas, worked through

Slope is the vertical change divided by the horizontal change, and everything else follows from it:

m = (y₂ − y₁) ÷ (x₂ − x₁)     // rise over run
b = y₁ − m·x₁               // substitute a known point
θ = arctan(m)               // angle from the horizontal
d = √((x₂ − x₁)² + (y₂ − y₁)²)  // Pythagoras

Take the example on load, (1, 2) to (4, 8). The rise is 6 and the run is 3, so m = 2. Substituting gives b = 2 − 2×1 = 0, making the line y = 2x — it passes exactly through the origin. The angle is arctan(2) ≈ 63.43°, the distance is √45 ≈ 6.708, and the midpoint is (2.5, 5).

The distance formula is just Pythagoras with the two coordinate differences as the short sides, which is why a 3-across, 4-up step gives exactly 5.

The two cases most calculators get wrong

A horizontal line has a slope of exactly zero: the rise is nothing, so m = 0, and the equation is y = a constant. A vertical line is genuinely different — the run is zero, and dividing by it has no answer at all. The slope is undefined rather than infinite, there is normally no y-intercept, and the line has to be written as x = a constant because it cannot be expressed as y = mx + b at all.

A related edge case: if you enter the same point twice, there is no unique line through it — infinitely many pass through a single point — so the tool asks you to change a coordinate rather than returning a meaningless zero.

FAQ

What does the slope actually tell me?

How steep the line is, and which way it leans. A slope of 2 means the line climbs 2 units for every 1 unit across; −0.5 means it drops half a unit for every unit across. Zero is perfectly flat.

Why is a vertical line "undefined" rather than infinite?

Because working it out requires dividing by the horizontal change, and for a vertical line that change is exactly zero. Division by zero has no answer, so the slope does not exist — it is not a very large number. The tool says "undefined" and gives you the line as x = a constant instead.

Does the order of the two points matter?

No. Swapping them flips the sign of both the rise and the run, and those cancel out — so (1,2) to (4,8) and (4,8) to (1,2) both give a slope of 2. The distance and midpoint are unchanged too.

What is the y-intercept when my line is vertical?

There usually is not one. A vertical line only crosses the y-axis if it sits exactly on it, at x = 0 — in which case it overlaps the axis entirely. The tool reports "none" or "every value" accordingly rather than printing a misleading number.

How is the angle calculated?

It is the arctangent of the slope, measured from the horizontal. A slope of 1 is exactly 45°, a slope of 2 is about 63.43°, and a negative slope gives a negative angle meaning the line descends. Vertical lines are reported as 90°.

Why show rise over run as a fraction?

Because it is often more useful than a decimal — a 6/3 slope reduces to 2/1, and a gradient like 1/12 is exactly how ramps and roof pitches are specified. Whole-number coordinates get the reduced ratio automatically.

How we compare

Feature Online Tool Store Ad-supported maths sites Graphing calculator
Handles vertical lines correctly Many return Infinity or an error
Angle, distance, and midpoint together Usually separate pages
Reduced rise/run ratio
No ads, nothing typed leaves the page
Draws the line on a graph Some do
Works with curves, not just straight lines

Handy for homework, for working out a ramp or roof gradient, and for any time you have two coordinates and need the line between them — with the vertical and identical-point cases answered honestly instead of returning a number that looks plausible. It does not plot anything; for that a graphing calculator is the right tool.

Explore related tools

Embed this tool

Paste this on your own site — it stays free, and every file still stays in your visitor's browser, not yours or ours.