Wireless sensor network (WSN) is self-organizing network; it consists of a large number of sensor nodes with perception, calculation ability and communication ability. As we all know, the floor, walls or people moving has an effect on indoor localization, so it will result in multi-path phenomena and decrease signal strength, also the received signal strength indicator (RSSI) is unable to gain higher accuracy of positioning. When using multilateral measurement method to calculate the unknown node coordinates, it will generate big error in range-free distance vector-hop (DV-hop) localization algorithm of WSN. In order to improve the WSN positioning accuracy in indoor condition, more reasonable distribute network resources, in this paper, we firstly propose krill swarm algorithm used for WSN localization. First, we detailed analyze the multilateral measurement method in DV-hop localization algorithm. The position problem can be transformed into a global optimization problem. Then, we adequately utilize the advantage of calculating optimization problem. We apply the krill swarm algorithm into the stage of estimating unknown node coordinates in DV-hop algorithm to realize localization. Finally, the simulation experience results show that the localization with krill swarm algorithm has an obviously higher positioning precision and accuracy stability with different anchor node proportion and nodes. We also make comparison with DV-hop algorithm and the newest localization algorithm.