Abstract Contour following is an important research topic for multi-axis CNC systems. In this paper, to simultaneously meet the challenges of accurate contouring error estimation and high-performance contouring control those are very significant for three-dimensional contouring following tasks, a numerical calculation based contouring error estimation and contour compensation scheme is proposed. Unlike any existing geometric approximation methods, the proposed scheme calculates the contouring error through a numerical calculation algorithm. Specifically, a cost function is defined as the spatial distance between the actual point and the point located on the reference contour. When the minimum value of the cost function is obtained through the numerical calculation, accurate contouring error vector can be obtained even under extreme contouring tasks with high-speed, large-curvature and sharp-corner. Then, the calculated contouring error is projected to each axis. After a zero-phase filter with low-pass characteristic, the axial contouring error is fed back to the corresponding axis as a kind of contour compensation. The added filter can effectively suppress the high-frequency noise widely existing in contouring error signal. Moreover, our proposed contour compensation scheme can be realized iteratively for further improvement of contouring performance. Various comparative experiments are performed to verify the effectiveness of the proposed contouring error estimation and compensation scheme. The results demonstrate that in comparison with traditional position loop CCC method, the proposed scheme can achieve not only nearly perfect contouring error estimation but also obvious promotion of contouring accuracy.