In order to solve the problem of reactive power optimization in power system, which is still a lack of a method that takes into account both the efficiency of optimization and the global search optimality. In this paper, a new heuristic algorithm called whale optimization algorithm(WOA) is applied to grid reactive power optimization, taking the lowest active power loss of the system as the objective function, a reactive power optimization model was established by introducing a penalty function to simulate the IEEE 14-bus system and the IEEE 30-bus system, and one-way ANOVA was used to compare the results of particle swarm optimization (PSO) algorithm and the particle swarm optimization with time varying acceleration coefficients (PSO-TVAC). The results show that the WOA algorithm has better performance in iteration times. search ability and convergence potential, it also proves the robustness and effectiveness in resolving the reactive power optimization problem of power system, and also provides a new way to solve the nonlinear constraint problem.