The G-code for CNC machining of free-form surfaces is usually composed of continuous line segments. The sudden change of velocity direction at the corner of adjacent line segments will cause the vibration of the machine tool, eventually affecting the machining quality. Therefore, this paper proposes a novel smoothing method for line segments based on the real-time transformation of interpolation points (SSTI). Firstly, this method generates a smoothing interval on the line-segment path, which centered on the current original interpolation point. Secondly, a smoothed interpolation point corresponding with the current interpolation point is obtained, by a transformation according to the line-segment path in the smoothing interval. Finally, to ensure the machining accuracy, the smoothing error of the smoothed interpolation point is checked and controlled. Compared with conventional smoothing methods, the SSTI method has no special requirements on the original line-segment path, such as the length of line segments, the angle of corners, and the quantity of endpoints. Simulation and experimental results show that the SSTI method proposed in this paper has good adaptability to different types of line-segment paths, and the smooth optimization can be achieved under the premise of ensuring machining accuracy. The proposed method offers an effective trajectory-optimization strategy for the CNC machining of continuous line-segment path.