# Slope Calculator - Slope, Intercept, and Line from Two Points

Compute m = (y2 − y1)/(x2 − x1), the inclination angle, distance, midpoint, y-intercept, and y = mx + b. Vertical lines are reported as undefined slope.

### Two Points

x1 _1_

y1 _2_

x2 _4_

y2 _8_

Clear All

Default points (1, 2) and (4, 8) give m = 2. Identical points error. Equal x-values with different y-values are a vertical line.

### Line Result

Slope, intercept, and the line equation will appear here

### What Is a Slope Calculator and Why Do You Need One?

A **slope calculator** takes two Cartesian points (x1, y1) and (x2, y2) and returns the slope of the unique line through them - when that slope exists. The definition is **m = (y2 − y1) / (x2 − x1)**, also called rise over run. When x1 equals x2 and the y-values differ, the run is zero, division is undefined, and the line is vertical with equation **x = x1**. When both coordinates match, there is no unique line at all; this page errors instead of inventing a slope of 0/0.

Algebra classes usually want m and the slope-intercept form **y = mx + b**. Surveying and physics often want the inclination angle arctan(m) in degrees, the Euclidean distance between the points, and the midpoint. This tool reports all of those for a non-vertical line. For a vertical line it still reports distance and midpoint (those never divide by dx) and it refuses to print a finite y-intercept, because a vertical line is not a function of x.

Everything runs in the browser. After you have a slope, the [triangle calculator](https://www.toolcomb.com/triangle-calculator) can turn three lengths or mixed angles into a closed shape, the [quadratic formula calculator](https://www.toolcomb.com/quadratic-formula-calculator) treats a parabola rather than a line, and the [scientific calculator](https://www.toolcomb.com/scientific-calculator) is there for a one-off arctan if you want to re-check the angle by hand.

### How to Use This Free Online Slope Calculator

Using this **two-point line equation tool**:

1. **Enter x1, y1, x2, and y2**. Negatives and decimals are allowed. Commas inside a number are stripped.
2. If the points coincide, you get an error. If only the x-coordinates coincide, you get a **vertical line** result: undefined slope, equation x = x1.
3. Otherwise read **m**, the angle atan(m) in degrees, distance, midpoint, intercept b = y1 − m x1, and the equation y = mx + b.
4. **Copy** the block of results, or clear the four fields. Last points stay in localStorage for up to 30 days.

**Note:** angle is atan(m), which lives in (−90°, 90°). A line with slope −2 is not reported as 243° measured from north, and this is not a compass bearing tool. Equality of x1 and x2 uses JavaScript === on the parsed numbers, not a fuzzy epsilon.

### Slope Formula from Two Points - Rise Over Run

m = (y2 − y1) / (x2 − x1)

Rise over run. Default (1, 2) and (4, 8) → m = 2

Rise is the change in y. Run is the change in x. On the default points the rise is 8 − 2 = 6 and the run is 4 − 1 = 3, so m = 2. Swapping the labels of the two points flips the sign of both rise and run, so m is unchanged: (2 − 8)/(1 − 4) = (−6)/(−3) = 2. A horizontal line has rise 0 and a defined slope 0. A vertical line has run 0 and no defined slope - this calculator writes “undefined,” not Infinity.

**Rise over run** is a phrase, not a second formula. Counting grid squares on graph paper is the same ratio if each square is 1 unit. If the graph is stretched so one vertical square is 10 units, you must use the axis scales, not pixel counts.

### What Is the Slope of a Vertical Line?

**Undefined.** If x1 === x2 and y1 !== y2, every point on the line shares that x-value, so the Cartesian equation is x = x1. You cannot solve for y as mx + b. Some computer systems print Inf; others throw. This page takes the geometry-class answer: undefined slope, equation x = x1, inclination 90° from the positive x-axis. Distance |y2 − y1| and the midpoint ((x1+x2)/2, (y1+y2)/2) remain ordinary numbers.

A nearly vertical line can produce a very large finite slope. This calculator classifies a line as vertical only when the two entered x-values are equal. Round measurements first if your problem uses a tolerance.

### Slope vs Gradient - Are They the Same?

In many British and Australian high-school texts, **gradient** is a synonym for the slope m of a straight line. In multivariable calculus, the gradient ∇f is a vector of partial derivatives, pointing uphill on a surface, not a single ratio (y2−y1)/(x2−x1). Road signs that say “8% grade” mean rise/run as a percent: m = 0.08, angle atan(0.08) ≈ 4.57°, not 8°. This calculator outputs the Cartesian m, not a percent grade and not a 3-D gradient field.

Parallel lines share m. Perpendicular lines in the Euclidean plane with two finite slopes satisfy m1 m2 = −1. A vertical line is perpendicular to every horizontal line (m = 0); you cannot multiply “undefined” by 0 and expect −1, which is why the vertical case is handled separately.

### How to Find the Y-Intercept from Two Points

Once m exists, pick either point: **b = y1 − m x1** or b = y2 − m x2. They agree if you used the same m. The intercept is the y-value where the line meets x = 0. On the default, m = 2 and b = 2 − 2·1 = 0, so the equation collapses to y = 2x. If both points have y = 5 and different x, then m = 0 and b = 5, a horizontal line y = 5. If the line is vertical, it never meets the y-axis or it is the y-axis itself (x = 0); slope-intercept form is the wrong language.

Point-slope form y − y1 = m(x − x1) is equivalent and does not mention b until you expand. This page expands it for you. Angle is atan(m) converted to degrees. For m = 2 that is atan(2) ≈ 63.4349488229°, not 60°. Distance is √[(x2−x1)²+(y2−y1)²]; midpoint averages each coordinate.

### Worked Examples - m = 2, Horizontal, and Vertical

**(1, 2) and (4, 8).** m = 6/3 = 2, b = 0, equation y = 2x, distance √45 = 3√5 ≈ 6.7082039325, midpoint (2.5, 5), angle atan(2) in degrees.

**(−2, 3) and (5, 3).** Rise 0, m = 0, b = 3, equation y = 0x + 3, i.e. y = 3. Angle 0°. Distance 7. Midpoint (1.5, 3).

**(4, 1) and (4, 9).** x1 === x2, y differs. Slope undefined, equation x = 4, distance 8, midpoint (4, 5).**(4, 1) and (4, 1)** is the same-point error.

### Point-Slope Form vs Slope-Intercept Form

After m is known, **point-slope** says y − y1 = m(x − x1). Expand: y = mx − m x1 + y1, so b = y1 − m x1, which is **slope-intercept** y = mx + b. This page prints the expanded form because algebra homework usually wants b visible. Both describe the same line. Vertical lines cannot be written either way as a function of x; they stay x = x1.

Standard form Ax + By = C is another rewrite. For y = 2x + 0 you can write 2x − y = 0. The calculator does not emit A, B, C integers; it shows m and b as decimal values. If a teacher wants “slope 2/3,” type points that produce that ratio (for example (0, 0) and (3, 2)) rather than expecting a fraction object.

### Distance Formula and Midpoint from Two Points

Distance is the Pythagorean theorem on the rise and run: d = √[(x2−x1)² + (y2−y1)²]. The default points give √(3²+6²) = √45 = 3√5. That length is independent of slope: a vertical segment still has a distance. The **midpoint** ((x1+x2)/2, (y1+y2)/2) is the average location; it lies on the segment even when slope is undefined.

These two extras are why a slope tool is more than m. A contractor who only needed “how steep” still often needs “how long is the brace” (distance) and “where is the midpoint hanger.” They come from the same four numbers. They do not require a y-intercept.

### Positive Slope, Negative Slope, and Zero Slope

If y increases as x increases, m is positive (uphill left to right). If y decreases, m is negative. If y is constant, m is 0 - a horizontal line, angle 0° with the positive x-axis. The sign of m is not the same as the sign of the intercept b. A line can have m = 2 and b = −4 (y = 2x − 4): it rises but crosses the y-axis below the origin.

Direction along the line is not encoded. Points (1, 2) and (4, 8) give the same m as (4, 8) and (1, 2). atan(m) therefore cannot tell you which way you walked; it only tilts the infinite line. Use atan2(dy, dx) yourself if you need a directed heading in (−180°, 180°]. This page does not.

### Parallel and Perpendicular Lines from Slope

Two non-vertical lines are **parallel** when they share m and **perpendicular** when m1 m2 = −1 (negative reciprocals). A vertical line is parallel to other verticals (all have undefined slope, all equations x = constant) and perpendicular to every horizontal line. You cannot plug “undefined” into m1 m2 = −1; handle that case with geometry instead of algebra on Infinity.

This calculator does not take a third point and test parallelism. Compute m twice, then compare. For a triangle’s side slopes, run the two endpoints of each side, then use the [triangle calculator](https://www.toolcomb.com/triangle-calculator) if you needed angles of the triangle rather than slopes of the supporting lines. A parabola through a vertex is not a line; that is the [quadratic formula calculator](https://www.toolcomb.com/quadratic-formula-calculator). One-off arctan lives on the [scientific calculator](https://www.toolcomb.com/scientific-calculator).

### How to Find Slope on a Graph

Pick two lattice points the line actually hits. Read their coordinates from the axes, not from pixel height. Count rise and run in axis units. If the x-axis is scaled by 10 and the y-axis by 1, a square on the paper is not a 1:1 run and rise. Type the true (x1,y1) and (x2,y2) here. Graphing software that snaps to pixels can invent a tiny dx and a huge m; that is a sampling artifact, not a vertical line unless the x-values compare equal.

Best-fit slope through a scatter plot is linear regression, not this two-point definition. Two noisy lab points will happily give you an exact m that the rest of the data would not agree with. Use a statistics tool for that job.

Percent grade is 100m. A wheelchair ramp at 1:12 has m = 1/12 ≈ 0.0833, about an 8.3% grade, angle atan(1/12) ≈ 4.76°. Highway “6%” is m = 0.06, not a 6° tilt. This page reports m and atan(m) in degrees, not a percent, so multiply m by 100 if a civil-engineering worksheet asked for grade. A roof pitch of 6:12 is m = 0.5, angle atan(0.5) ≈ 26.57°, which is not the same as a “6/12 grade” spoken as six percent.

### Honest Limits of This Slope Calculator

- **Two points in the plane** only. No 3-D direction vectors, no polar r, θ input, no regression through a cloud of points.
- **Vertical test is ===** on parsed floats, not “almost vertical.”
- **atan(m) in (−90°, 90°)**, not a heading from north and not a two-argument atan2 that would distinguish direction along the line.
- **Not a graphing calculator.** It does not plot. Copy m and b into whatever you draw with.

### Frequently Asked Questions (FAQ) - Slope Calculator

#### What is the slope formula from two points?

m = (y2 − y1) / (x2 − x1). That is rise over run: the change in y divided by the change in x. Default example: (1, 2) and (4, 8) give m = 6/3 = 2.

#### What does rise over run mean?

Rise is y2 − y1 (up is positive in the usual Cartesian plane). Run is x2 − x1 (right is positive). Slope 2 means you go up 2 for every 1 you go right, or up 6 for a run of 3. Order of the points does not change m: swapping them flips the sign of both rise and run.

#### What is the slope of a vertical line?

Undefined. A vertical line has x1 = x2 and y1 ≠ y2, so you would divide by zero. This calculator does not print Infinity. It reports an undefined slope and the equation x = x1. Distance and midpoint are still defined.

#### What is the difference between slope and gradient?

In a 2D algebra class, slope and gradient often mean the same number m. In multivariable calculus, gradient is a vector of partial derivatives, not a single slope. Road signs that say “6% grade” are rise/run as a percent, which is 100m if m is the slope. This page computes the Cartesian m from two points, not a 3D gradient field.

#### How do you find the y-intercept from two points?

First get m, then b = y1 − m x1 (or y2 − m x2; they match). The intercept is the y-value where the line hits x = 0, so the equation is y = mx + b. A vertical line has no y-intercept in this form. A horizontal line has m = 0 and b equal to the constant y.

#### Does this slope calculator upload my points?

No. Arithmetic runs in your browser with JavaScript. Nothing is sent to a server. After the page loads, the tool still works if the network drops. The last coordinates are stored only in localStorage on this device for up to 30 days.

### Why Choose Our Slope Calculator?

- **Free, no account.** Unlimited two-point lines.
- **Private.** Coordinates stay on this device.
- **Vertical lines handled honestly** - undefined slope, x = x1, not a fake Infinity.
- **Same-point error** instead of 0/0.
- **Angle, distance, midpoint, intercept, and equation** in one panel.
- **Works offline** after the first page load.

## Related Tools

Discover more free tools that might help with your next task.

[Area Calculator Calculate area of squares, rectangles, triangles, circles, and more Use Tool](https://www.toolcomb.com/area-calculator)

[Average Calculator Calculate mean, median, mode, and range from a list of numbers Use Tool](https://www.toolcomb.com/average-calculator)

[Basic Calculator Add, subtract, multiply, and divide with a free online calculator Use Tool](https://www.toolcomb.com/basic-calculator)

[Big Number Calculator Add, subtract, multiply, and divide integers too large for a standard calculator Use Tool](https://www.toolcomb.com/big-number-calculator)

[Binary Calculator Add, subtract, and convert binary numbers to decimal and hex Use Tool](https://www.toolcomb.com/binary-calculator)

[Circle Calculator Find radius, diameter, circumference, area, arc length, and sector area Use Tool](https://www.toolcomb.com/circle-calculator)

### Related guides

Read the how-to, then come back to this tool when you are ready to run it locally.

- [Quadratic Formula, Discriminant, and Roots: When Factoring Fails Solve ax²+bx+c=0 with the discriminant b²−4ac, real vs complex roots, and the vertex. A homework workflow for when factoring does not work.](https://www.toolcomb.com/blog/quadratic-formula-discriminant-and-roots)

[View All Tools](https://www.toolcomb.com/tools)
