Slope calculator
Enter two points and get the slope of the line through them: from (1, 2) to (4, 8) the rise is 6 and the run is 3, so the slope is 2 and the line climbs at about 63.4 degrees. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- X1
- 1
- Y1
- 2
- X2
- 4
- Y2
- 8
- Rise
- 6
- Run
- 3
- Slope
- 2
- Angle deg
- 63.4349488229
The slope calculator finds the slope of the unique line through two points and the angle that line makes with the positive x-axis. You enter the coordinates of the first point and the second point; the engine computes rise over run, m equals (y2 minus y1) divided by (x2 minus x1), then takes the inverse tangent of m to report the angle of inclination in degrees and radians. Coincident points are rejected for the same reason: two identical coordinates do not determine a unique line. Results are deterministic floating-point arithmetic with no random sampling and no network call.
What slope and inclination mean
In analytic geometry the slope of a non-vertical line is the constant rate of change of y with respect to x along that line. If you travel from point A equals (x1, y1) to point B equals (x2, y2), the vertical change is the rise y2 minus y1 and the horizontal change is the run x2 minus x1. Their ratio m equals rise over run is the slope: positive when the line climbs as x increases, negative when it falls, and zero when the line is horizontal.
The angle of inclination is the unique angle theta in the open interval from negative ninety degrees to positive ninety degrees such that the tangent of theta equals m; equivalently theta equals the two-argument free arctangent of m along the real line. That angle measures how steeply the line tilts relative to the positive x-axis and is the quantity surveyors, road designers, and physics teachers often want alongside the raw slope number.
This calculator returns both coordinates echoed for audit, the rise and run, the slope, the inclination in degrees and radians, a direction label of increasing, decreasing, or horizontal, and a short formula string restating the identities. The contract is intentionally strict. If you need triangle specials, circumcenters, or ambiguous SSA cases, use those dedicated geometry tools; the search intent here is specifically the two-point slope formula and a clear answer of m and theta or an honest error.
Where two-point slope solving fits in study, design, and code
Students meet the slope formula early when linear equations are introduced. A textbook may give two lattice points and ask for m, for the angle of inclination, or for a check that a horizontal segment has slope zero; this calculator returns those numbers in one shot with the formula made explicit. Teachers can pre-generate answer keys that list rise, run, slope, and degrees, and refuse vertical and coincident inputs instead of printing a blank or a silent Infinity.
Builders, surveyors, and game-level designers often need the pitch of a ramp or the tilt of a segment between two waypoints; converting coordinate pairs into a slope and an angle without a hand calculator or a misremembered arctangent avoids layout mistakes. Developers call the same contract from scripts to seed deterministic test vectors for geometry libraries, to illustrate linear equations in teaching tools, or to satisfy programming-challenge statements that demand exact two-point slope completions.
What you can do with it
Ramps, roofs, and path pitch
Convert two design coordinates into a slope and tilt angle for carpentry pitch, road grade sketches, and game geometry waypoints.
FAQ
What does the slope calculator cost?
It is free in your browser on this page.
How is the slope calculated from two points?
m = (y2 − y1) / (x2 − x1). That is rise over run. The angle of inclination is θ = atan(m), reported in degrees and radians.
What happens if the line is vertical?
When x1 equals x2 and the y-coordinates differ, the slope is undefined.
What if both points are the same?
Coincident points do not define a unique line.
What does a slope of zero mean?
A slope of zero means the line is horizontal: y does not change as x changes. The direction field is reported as horizontal and the inclination is zero degrees.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/geom/slope \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"x1":1,"y1":2,"x2":4,"y2":8}'const res = await fetch("https://api.kit.forhosting.com/geom/slope", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"x1": 1,
"y1": 2,
"x2": 4,
"y2": 8
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/geom/slope",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"x1": 1,
"y1": 2,
"x2": 4,
"y2": 8
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/geom/slope", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"x1":1,"y1":2,"x2":4,"y2":8}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"x1":1,"y1":2,"x2":4,"y2":8}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/geom/slope", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"x1": 1,
"y1": 2,
"x2": 4,
"y2": 8
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "geom.slope",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
What slope and inclination mean and what the response contains
Missing coordinates, non-finite values, coincident points, and vertical lines all raise invalid_input with a message that names the failing condition.
How the four coordinates are read and how m and theta are computed
All four must be present and finite. Computation is elementary: rise is y2 minus y1, run is x2 minus x1. Otherwise slope equals rise divided by run, the inclination in radians is Math.atan of that slope, and the degree form multiplies by one hundred eighty over pi. Direction is horizontal when the slope is exactly zero, increasing when positive, and decreasing when negative. There is no third point, no least-squares fit, and no unit conversion of the coordinates themselves; the arithmetic assumes a shared Cartesian frame. The preferred fields are x1, y1, x2, and y2 as JSON numbers, but decimal strings are accepted for form and spreadsheet callers. Aliases x_1 and a_x map to x1; y_1 and a_y map to y1; x_2 and b_x map to x2; y_2 and b_y map to y2. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing rise-over-run yourself.
Where two-point slope solving fits in study, design, and code
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split—free interactive exploration and a priced, identical API—matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result. Pair it with unit converters when coordinates arrive in mixed units, with other free math endpoints when you need series or combinatorial companions for a lab of deterministic tools, and with graphing notes that show students the rise-over-run triangle so the numbers and the figure stay aligned.
Integration use cases
Homework and exam preparation
Compute textbook slope problems from two lattice points, check inclination in degrees, and confirm that vertical inputs fail with invalid_input instead of Infinity.
Deterministic geometry fixtures
Generate reproducible rise, run, slope, and angle triples for unit tests, contest validators, and CI assertions without hand-rolled atan arithmetic.