Harmonic minimization in PWM inverters is a complex optimization problem which involves non-linear transcendental equations having multiple local minima. In this paper, a solution to the harmonic minimization problem using the particle swarm optimization (PSO) has been proposed to solve the SHE problem. It overcomes the complicated computations associated with conventional iterative techniques. As an example, in this paper a bipolar PWM inverter with seven switching angles per quarter cycle with varying modulation index is considered, and the optimum switching angles are calculated offline to eliminate the 5th,7th, 11th,13th,17th and 19th harmonics. The simulated results are also validated by experiment.