Skip to content
QueenNexa

Free tool

Slope Calculator: Slope, Equation & Angle from Two Points

Enter two points to get the slope as a decimal and a reduced fraction, the line equation in y = mx + b form, the angle, the distance and the midpoint, with working.

Slope (m)
–
Slope as a fraction
–
Equation of the line
–
y-intercept (b)
–
Angle with the x-axis
–
Distance between the points
–
Midpoint
–

The working

    Assumptions

    These are estimates from your own inputs, not a forecast or a promise of results. No vendor prices or industry averages are built in: every number comes from you.

    • Slope m = (y₂ − y₁) ÷ (x₂ − x₁), the rise divided by the run.
    • y-intercept b = y₁ − m × x₁, so the line is y = mx + b.
    • Angle = arctan(m), in degrees from the positive x-axis. Distance = √((x₂ − x₁)² + (y₂ − y₁)²). Midpoint = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2).
    • When x₁ = x₂ the line is vertical: the slope is undefined and the equation is x = x₁. Decimals are rounded to 6 places; the fraction is exact when the rise and run are whole numbers.

    Runs entirely in your browser. Nothing you type or upload is sent to our servers.

    How the slope calculator works

    Slope measures how steep a line is: how far it rises (or falls) for each step to the right. Enter any two points and the calculator finds the rise and the run, divides them, and then uses the slope to build the full line equation, the angle the line makes with the x-axis, the distance between the points and the point halfway between them.

    Worked example 1: a rising line

    1. Points (1, 2) and (4, 8). Rise = 8 − 2 = 6. Run = 4 − 1 = 3.
    2. Slope m = 6 ÷ 3 = 2.
    3. Intercept b = 2 − 2 × 1 = 0, so the line is y = 2x.
    4. Angle = arctan(2) ≈ 63.43°. Distance = √(3² + 6²) = √45 ≈ 6.708204. Midpoint = (2.5, 5).

    Worked example 2: a falling line with a fractional slope

    1. Points (−2, 3) and (4, −1). Rise = −1 − 3 = −4. Run = 4 − (−2) = 6.
    2. Slope m = −4 ÷ 6 = −2/3 ≈ −0.666667.
    3. Intercept b = 3 − (−2/3)(−2) = 3 − 4/3 = 5/3 ≈ 1.666667, so the line is y = −(2/3)x + 5/3.
    4. Angle ≈ −33.69°. Distance = √(6² + 4²) = √52 ≈ 7.211103. Midpoint = (1, 1).

    Common mistakes

    • Mixing the order: (y₂ − y₁) on top must be matched by (x₂ − x₁) underneath, not (x₁ − x₂).
    • Putting the run on top. Slope is rise over run, not run over rise.
    • Calling a vertical line's slope zero. Zero is horizontal; vertical is undefined.

    Related tools

    Find the length of a right triangle's sides with the Pythagorean Theorem Calculator, solve second-degree equations with the Quadratic Formula Calculator, and simplify ratios with the Ratio Calculator.

    Frequently asked questions

    How do I find the slope from two points?

    Subtract the y values and divide by the difference of the x values in the same order: m = (y₂ − y₁) ÷ (x₂ − x₁). For (1, 2) and (4, 8), the rise is 8 − 2 = 6 and the run is 4 − 1 = 3, so the slope is 6 ÷ 3 = 2. The order of the points does not matter as long as you keep it the same on the top and bottom.

    What does a negative slope mean?

    The line falls as you move to the right. For (−2, 3) and (4, −1), y drops by 4 while x rises by 6, so the slope is −4/6, which reduces to −2/3, about −0.666667. A positive slope rises to the right, a slope of 0 is a flat horizontal line, and a larger number in either direction means a steeper line.

    Why is the slope of a vertical line undefined?

    A vertical line has a run of zero, and division by zero has no value. For (3, 1) and (3, 9), x₂ − x₁ = 0, so the calculator reports the line as x = 3 with an angle of 90 degrees instead of a slope. A horizontal line is the opposite case: its rise is zero, so its slope is exactly 0.

    How do I write the equation of the line?

    Find the slope m, then the y-intercept b = y₁ − m × x₁, and write y = mx + b. With slope −2/3 through (−2, 3): b = 3 − (−2/3)(−2) = 3 − 4/3 = 5/3, about 1.666667. So the line is y = −0.666667x + 1.666667, or y = −(2/3)x + 5/3 in exact form.

    How is slope related to an angle or a grade?

    The angle is the inverse tangent of the slope: a slope of 1 is 45 degrees and a slope of 2 is about 63.43 degrees. A road or ramp grade is the slope written as a percentage, so a slope of 0.05 is a 5% grade, a rise of 5 feet for every 100 feet of run.

    Can I use decimals and negative numbers?

    Yes. Any real numbers work. When the rise and run are both whole numbers, the calculator also shows the slope as a reduced fraction, such as 6/3 shown as 2 or −4/6 shown as −2/3. With decimals it shows the slope as a decimal only, rounded to six places.

    Is anything I enter sent anywhere?

    No. The calculation runs in your browser, nothing is stored and nothing is sent to our servers. Analytics record only that the tool was used, never your numbers.

    Link to this tool

    Found it useful? Copy a link for your page, newsletter or documentation.

    Get new tools and guides by email

    Optional. The tool above works without signing up.

    One email every Tuesday. Free, and you can unsubscribe in one click.

    More free tools

    Browse all everyday calculators or the full list of free tools.