Point to Line Distance Calculator

Measure the shortest distance from a point to a line and locate the foot of the perpendicular.

Math and PercentUpdated 2026-11-184 min read
Point to Line Distance Calculator
Write the line as Ax + By + C = 0 before entering.
Perpendicular distance
...
Closest point on the line...
Absolute value in the numerator...
Square root in the denominator...
Position relative to the line...

What it does

Given a point and a line in the plane, exactly one shortest segment joins them, and it meets the line at a right angle. Mathematics LibreTexts builds this from a simple fact: in a right triangle the hypotenuse is longer than either leg, so any slanted segment from the point to the line must be longer than the perpendicular one. That perpendicular length is what we call the distance from the point to the line.

To compute it, write the line in general form Ax + By + C = 0. The coefficients A and B form a normal vector, perpendicular to the line, and the expression Ax0 + By0 + C tells how far the point sits along that normal before dividing by the vector's length. The absolute value removes the sign, because a distance is never negative.

The formula works for horizontal and vertical lines as well as slanted ones. Set A to zero and the line becomes horizontal; set B to zero and it becomes vertical. The denominator stays the square root of A squared plus B squared, so no separate rule is needed for either case.

This page takes the point coordinates and the three line coefficients directly. It returns the perpendicular distance, the absolute value used in the numerator, the denominator, and the foot of the perpendicular, which is the exact point on the line closest to your point. A short note also tells you which side of the line the point lies on.

Coordinates are plain numbers in a flat Cartesian plane, so there is no unit selector. If x and y are measured in metres the distance is in metres; if they are pixels it is in pixels. Keep both coordinates in the same system, and write the line by moving every term to one side of the equation.

How to use

  1. Rewrite your line so every term sits on one side, leaving Ax + By + C = 0.
  2. Enter A, the coefficient of x, including its sign.
  3. Enter B, the coefficient of y, and C, the constant term.
  4. Enter x0 and y0, the coordinates of the point you are measuring from.
  5. Read the main distance first, then the foot of the perpendicular and the numerator and denominator used.
  6. Check your work by substituting the foot coordinates back into Ax + By + C; the result should be zero.

Formula

d = |A x0 + B y0 + C| / sqrt(A^2 + B^2), for a line Ax + By + C = 0 with A and B not both zero.
x0
The x coordinate of the given point.
y0
The y coordinate of the given point.
A
The coefficient of x in the general form of the line.
B
The coefficient of y in the general form of the line.
C
The constant term in the general form of the line.

Both A and B cannot be zero, since that would not describe a line. The result is unchanged if you multiply A, B and C by the same nonzero number, so 6x + 8y minus 12 = 0 gives the same distance as 3x + 4y minus 6 = 0. If Ax0 + By0 + C equals zero the point already lies on the line and the distance is zero. The foot of the perpendicular is found by subtracting A times the signed value divided by A squared plus B squared from x0, and the same expression with B from y0.

Worked example

Example: point (2, 3) and the line 3x + 4y minus 6 = 0

Defaults: x0 = 2, y0 = 3, A = 3, B = 4 and C = -6.

  1. The line is already in general form, so A = 3, B = 4 and C = -6.
  2. Numerator: |Ax0 + By0 + C| = |3 x 2 + 4 x 3 minus 6| = |6 + 12 minus 6| = |12| = 12.
  3. Denominator: sqrt(A^2 + B^2) = sqrt(9 + 16) = sqrt(25) = 5.
  4. Distance: 12 / 5 = 2.4. The main answer reads 2.4.
  5. Foot of the perpendicular: x = 2 minus 3 x 12/25 = 0.56 and y = 3 minus 4 x 12/25 = 1.08.
  6. Check: 3 x 0.56 + 4 x 1.08 minus 6 = 1.68 + 4.32 minus 6 = 0, so the foot lies on the line.
  7. The signed value is positive, so the point is reported on the positive side of the line.

Reference table

Distances from several points to the line 3x + 4y minus 6 = 0
Point (x, y)Ax + By + CDistance
(2, 3)122.4
(0, 0)-61.2
(5, 5)295.8
(2, 0)00
(-2, -3)-244.8

Limits

  • Applies to a straight line in a two dimensional plane, not to a segment or a ray, where the closest point could be an endpoint.
  • Does not measure distance to a curve or to a plane in three dimensions.
  • Assumes the line is already in general form; coefficients from a slope intercept form must be rearranged first.
  • Very large coordinates or coefficients can lose precision when squared, so the page caps each input.

Common mistakes

  • Forgetting the absolute value and reporting a negative distance.
  • Using the distance between two points formula instead of the point to line formula.
  • Taking line coefficients from y = mx + b without moving every term to one side.
  • Scaling only some of A, B and C, which changes the line being measured against.
  • Assuming the foot of the perpendicular must have positive coordinates; it can land anywhere on the line.

Try it yourself

Quick checks. Answers sit tucked under each question.

Find the distance from (-1, 4) to the line x minus 2y + 5 = 0.

Ax0 + By0 + C = -1 minus 8 plus 5 = -4, and sqrt(1 + 4) = 2.2361. The distance is 4/2.2361 = 1.7889. The tool reports 1.7889 with foot (-0.2, 2.4).

What is the distance from the origin to 5x minus 12y + 13 = 0?

The numerator is 13 and the denominator is sqrt(25 + 144) = 13, so the distance is 1. The tool reports 1 and the foot (-0.3846, 0.9231).

A point gives Ax0 + By0 + C = 0. What is the distance?

Zero. The point already lies on the line, and the foot of the perpendicular is the point itself. The tool reports 0 and notes that the point lies on the line.

Questions

Why is the shortest segment perpendicular to the line?

Any other segment from the point to the line forms the hypotenuse of a right triangle whose leg is the perpendicular, and a hypotenuse is always longer than either leg.

What if A and B are both zero?

Then the equation is not a line. The page rejects the input and asks for at least one nonzero coefficient.

Does multiplying the line equation by a constant change the answer?

No. The constant cancels between numerator and denominator, so 3x + 4y minus 6 = 0 and 6x + 8y minus 12 = 0 give the same distance.

How do I handle a vertical line?

Set B = 0. The line x = 4 becomes 1x + 0y minus 4 = 0, and the distance from (1, 1) is 3.

What does a negative numerator mean?

Only that the point lies on the negative side of the line. The absolute value turns it into a positive distance, and the note on the page tells you which side.

Can this find the distance to a line segment?

Not directly. This is the distance to the infinite line. For a segment, compare this result with the distances to both endpoints and take the smallest if the foot falls outside the segment.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.