Wireless sensor networks play essential role in daily life scenarios due to their wide range of applications. These networks are widely adopted in to accomplish several tasks such as smart cities, smart transportation, weather monitoring etc. These networks have limited resources and suffer from various challenges which impact their performance. Moreover, these networks collect the event information and if the location of information is not known then the data becomes meaningless. Therefore, localization is considered as the important aspect of these networks. Initially, Global Positioning System (GPS) based localization was considered as solution for localization but these networks consist huge number of nodes which increases the cost of network deployment. GPS won't deliver accurate localization outcomes in an indoor environment. In dense network, manually establishing location reference for each sensor node is also a tedious task. This creates a situation where the sensor nodes must locate themselves without any specialised hardware, such as GPS, or manual configuration. Utilizing localization methods, Wireless Sensor Networks (WSNs) may be deployed with reduced cost. Localization accuracy and complexity still remains the challenging issue for traditional methods. Therefore, in this work, we introduce optimization-based method where we consider antlion optimization as base method and incorporate particle swarm-based position and velocity update method to increase the localization performance. The experimental study shows that the average localization error is obtained as 0.