Node localization is a key technology of wireless sensor network applications. Considering the resource constraints of senor nodes, node localization is transformed into an unconstrained optimization problem, then one distributed localization algorithm based on particle swarm with adaptive inertia weight is put forward. The unknown nodes construct particle region using the received information of their neighbor anchor nodes, which can reduce the search scope and save the computational cost of the algorithm. Mean deviation of the distances which are the particles to the global optima can be computed to characterize the distribution of particles, and is used to adaptively adjust the inertia weight to avoid falling into the local optima. Simulation shows that the proposed algorithm has a good localization performance.