Distance from a Point to a Line Explained: Formula & Examples
ByMuhammad Ali•Founder of KruskalCode
17:25
7 min read

Understanding how to find the distance from a point to a line is a fundamental concept in geometry and algebra. Whether you're working on homework, preparing for an exam, or just curious, this skill helps you grasp the relationship between points and lines in a coordinate system. This guide will break down the formula, walk you through examples, and show you how our online calculator can make these calculations a breeze.
Explanation
The distance from a point to a line refers to the shortest possible distance between a given point and any point on the line. This shortest path is always along a line segment that is perpendicular to the original line. To calculate this, we use a specific formula that involves the coordinates of the point and the coefficients of the line's equation. Consider a point P with coordinates (x₀, y₀) and a straight line L defined by the equation Ax + By + C = 0. The formula for the perpendicular distance (D) from point P to line L is derived using principles of vector projection or by minimizing the distance function, and it looks like this:
Formula
D = |Ax₀ + By₀ + C| / √(A² + B²)
Example
Let's apply this formula to a real example. Suppose we want to find the distance from the point (5, -3) to the line 3x - 4y + 10 = 0. First, identify your values: Point (x₀, y₀) = (5, -3) Line Ax + By + C = 0, so A = 3, B = -4, C = 10 Now, plug these values into the formula: D = |(3 * 5) + (-4 * -3) + 10| / √(3² + (-4)²) D = |15 + 12 + 10| / √(9 + 16) D = |37| / √25 D = 37 / 5 D = 7.4 So, the shortest distance from the point (5, -3) to the line 3x - 4y + 10 = 0 is 7.4 units.
How to use the related calculator
Using our Distance from a Point to a Line Calculator is straightforward. First, make sure your line equation is in the standard form Ax + By + C = 0. Then, simply enter the coefficients A, B, and C into their respective fields. Next, input the x-coordinate (x₀) and y-coordinate (y₀) of your point. Once all values are entered, the calculator will instantly display the shortest distance, helping you check your work or quickly solve problems.
Try the related calculator
Open toolFAQ
What if my line equation is in y = mx + b form?
If your line is in slope-intercept form (y = mx + b), you need to rearrange it into the standard form Ax + By + C = 0. For example, y = 2x + 5 becomes 2x - y + 5 = 0. In this case, A = 2, B = -1, and C = 5.
Does the order of A, B, and C matter?
Yes, the order is crucial. A is always the coefficient of x, B is the coefficient of y, and C is the constant term. Ensure you match them correctly to avoid errors in your calculation.
Can this formula be used for 3D space?
The formula presented here is specifically for 2D Cartesian coordinates. Calculating the distance from a point to a line in 3D space involves a slightly different vector-based approach.
Related articles

About the author
Muhammad Ali. Muhammad Ali is a full-stack developer and founder of KruskalCode. He builds SaaS platforms and automation systems with React and Laravel, and helps teams ship fast, scalable tools.
Need a custom calculator, dashboard, or automation workflow? Reach out to KruskalCode.