The invention provides a method for optimizing off-line planned welding gun pose in robot pipeline welding, and belongs to the field of welding gun pose optimizing and adjusting in pipeline welding. According to the method, firstly, a structured light measurement system for off-line planned welding gun pose optimization is built, and system parameters are calibrated; then, pipeline welding path points are off-line planned; a welding gun is adjusted to a desired pose, a phase diagram corresponding to the pose is generated, visual features of visual servo are extracted from the phase diagram, and a visual servo control law is designed; and at each off-line planned path point, the pose of each path point is optimized based on the visual servo control law, and corresponding angles of robot joints are recorded. According to the method, the advantages that structured light measurement is high in precision and visual servo control is high in precision are combined, and the advantage that a robot is high in repeated positioning precision is fully utilized, so that the pose of the welding gun in the actual welding process can be effectively optimized.