Distributed generation has attracted great attention in recent years, thanks to the progress in new-generation technologies and advanced power electronics. And micro-grid can make full use of distributed generation, so it has been widespread concern. On the other hand due to the extensive use of power electronic devices and many of the loads within micro-grid are nonlinear in nature, Micro-grid generate a large number of harmonics, so harmonics pollution needs to be addressed. Usually we use passive filter to filter out harmonic, in this paper, we propose a new method to optimize the filter parameters, so passive filter can filter out harmonic better. This method utilizes immune particle swarm optimization algorithm to optimize filter parameters. It can be shown from the simulation results that the proposed method is effective for micro-grid voltage harmonics compensation.