The invention belongs to the technical field of error compensation for large numerical control machine tools or large friction stir welding equipment, and particularly relates to a ram overhanging deformation compensation device and method. The device comprises a saddle, a ram, a column, a force sensor and center-of-mass regulating mechanisms. The column is provided with a rectangular through hole I in the vertical direction. The saddle is disposed in the rectangular through hole I of the column and slidably connected with the front end of the column and the inner wall of the rectangular through hole I in the vertical direction. The saddle is provided with a rectangular through hole II in the length-wise direction. The ram is inserted into the rectangular through hole II of the saddle and slidably connected with the saddle in the horizontal direction. The saddle moves in the rectangular through hole I of the column in the vertical direction, and the ram extends or retracts in the rectangular through hole II of the saddle. One side or two sides of the saddle are provided with the center-of-mass regulating mechanisms; the force sensor is disposed at the sliding connection of the saddle with the front end of the column. The ram overhanging deformation compensation device has the advantages that compensation torque is large, compensation effect is good, precision is high, response speed is high, and dynamic performance is good.