Aiming at the problem of large amount of calculation and difficulty in convergence of robot path planning in complex underwater 3D environments, the paper proposes a 3D path planning algorithm based on the sparrow search algorithm with potential field heuristic. First, establish an underwater 3D grid model, and use artificial potential field forces to generate an initial feasible path. Secondly, use the infinite folding chaotic map to expand the sparrow population and increase the diversity of the population.Then use the dynamic adjustment strategy to improve the location update formula of the sparrow search algorithm to adjust the search area range. Finally, the improved algorithm proposed is applied to solve the 3D path planning problem of underwater robots. The simulation results show that the optimization performance of the potential field sparrow search algorithm (PFSSA) proposed in this paper is better than the particle swarm optimization algorithm (PSO) and the sparrow search algorithm (SSA), and it can quickly obtain an optimal and safe feasible path, which proves the effectiveness of the method, and it has application value in the field of path planning of underwater robot.