Slope Calculator — Slope, Equation, Angle, Grade
Compute slope from two points or rise/run. Get the equation, angle, distance, and percent grade.
- Equation
- —
- Angle
- —
- Distance
- —
- y-intercept
- —
What is slope calculator?
The slope of a line measures its steepness — how much y changes per unit of x. Algebra students learn it as m = (y₂ - y₁) / (x₂ - x₁); civil engineers and accessibility designers usually express the same quantity as a percent grade or a rise:run ratio. This calculator covers both framings: switch to Two points for the algebra-class question (slope, equation, angle, distance), or to Rise / run for the engineering question (percent grade, angle, simplified ratio).
The two-points mode handles a few edge cases explicitly. A vertical line — where x₁ equals x₂ — has undefined slope; the calculator detects this and switches the line equation to x = c form, which is what a textbook expects. A horizontal line has slope 0 and an equation of the form y = c. Coincident points (identical (x, y)) return a hint asking for two distinct points.
In rise / run mode, the ratio is reduced to lowest terms via GCD when both numbers are integers, so a rise of 4 over a run of 12 displays as 1:3 rather than 4:12. Non-integer inputs fall back to 1:N formatting with N rounded to 4 decimals.
Privacy is simple: every calculation runs locally. The only saved state is your mode preference in localStorage.
When to use a slope calculator
- Algebra homework — slope between two points — Type the two coordinates and read the slope, y-intercept, full <code>y = mx + b</code> line equation, the angle of inclination, and the Euclidean distance between the points. Vertical lines (x₁ = x₂) are handled explicitly — the slope is reported as undefined and the equation switches to <code>x = c</code> form.
- Civil engineering — convert rise/run to percent grade — Highway and rail grades are reported as percentages. Switch to Rise / run mode, type the vertical and horizontal distances, and the calculator returns the slope as a decimal, the percent grade, the angle in degrees, and a reduced <code>rise:run</code> ratio. Useful for road grades, drainage runs, and ramp planning.
- Accessibility — ramp gradient checks — ADA recommends a maximum 1:12 ratio (8.33%) for accessibility ramps. Type the rise (curb height) and run (ramp length); the percent grade tells you whether you're within or over the recommended threshold.
How to use the Slope Calculator — Slope, Equation, Angle, Grade
- Pick the mode — Two points if you have coordinates (x₁, y₁) and (x₂, y₂); Rise / run if you have vertical and horizontal distances. Your last choice persists across visits.
- Fill all the fields in the active group — Two points needs all four coordinates. Rise / run needs both rise and run, with run > 0 and rise ≥ 0.
- Read the slope in the headline — The headline shows the slope as a decimal. For vertical lines (two-points mode only), the slope reads as 'undefined (vertical line)'. The stats list contains the equation (or percent grade in rise/run mode), the angle of inclination in degrees, and either the distance between points or the simplified rise:run ratio.
- Copy the summary — Tap the copy button to put a one-line summary on your clipboard.
Worked examples
(0, 0) → (3, 6)
Input: Mode Two points; x₁=0, y₁=0, x₂=3, y₂=6
Output: Slope = 2, equation y = 2x, angle ≈ 63.43°, distance ≈ 6.71 Vertical line (2, 0) → (2, 5)
Input: Mode Two points; x₁=2, y₁=0, x₂=2, y₂=5
Output: Slope = undefined (vertical line), equation x = 2, angle = 90°, distance = 5 When x₁ = x₂, the slope formula divides by zero. The calculator detects this and switches the equation to <code>x = c</code> form.
Rise 1 ft, Run 12 ft (ADA ramp)
Input: Mode Rise / run; rise = 1, run = 12
Output: Slope ≈ 0.0833, grade ≈ 8.33%, angle ≈ 4.76°, ratio 1:12 The canonical ADA-compliant ramp ratio. 1:12 is the maximum recommended slope for accessibility ramps.
Frequently asked questions
What is the slope formula?
m = (y₂ - y₁) / (x₂ - x₁) — the change in y divided by the change in x between any two points on a line. The same value works regardless of which two points you pick, as long as they lie on the same line.How do I find the y-intercept once I know the slope?
y = mx + b and solve for b. The calculator does this automatically: b = y₁ - m·x₁. The result appears in the equation line as the constant term and separately in the stats list as the y-intercept.What happens when the two points are vertical (same x)?
y = mx + b — it has the form x = c, where c is the shared x-value. The calculator detects this case and reports the slope as undefined with the equation in x = c form. The angle is 90° and the distance is just |y₂ - y₁|.How do percent grade and slope relate?
grade = slope × 100. A 1:12 ramp (1 unit up for every 12 units across) has slope 1/12 ≈ 0.0833, which is an 8.33% grade. Highway grades, rail grades, and accessibility ramps are usually reported as percent grade because most readers find percentages easier to interpret than decimals.What does a 1:12 ratio mean?
How is the angle calculated?
arctan(slope), converted to degrees. For slope 1 the angle is 45°; for slope 2 it's ~63.43°. Vertical lines give 90°; horizontal lines give 0°. The calculator uses Math.atan internally and rounds the result to 4 decimals.Why is run restricted to > 0 in rise/run mode?
Are my numbers stored or sent anywhere?
localStorage so the toggle remembers your last choice.