The optimization of the inverse kinematics of robots is the most important part of robot kinematics. In view of the fact that to get the analytic solutions of the inverse kinematics of robots must meet special conditions, this paper used improved firefly algorithm to get the optimization of inverse kinematics without any of special conditions. This method is not affected by the structure of the robot. All the inverse solutions can be identified and the most appropriate one can be selected. Simulation results show that, the algorithm can be effectively applied to the robot inverse kinematics, and is able to achieve sufficient accuracy.