Abstract: This study deals with the design, analysis and simulation of shunt active power filter SAPF which compensate harmonic currents and reactive power under balanced supply network. An optimal control theory for currents compensation based on particle swarm optimization is developed in this study. The SAPF is connected in parallel with a nonlinear load which has caused current harmonics in industrial power plants and utility power distribution systems. The proposed optimal PI current controller using particle swarm algorithm determines the switching signals of the SAPF and the algorithm based on instantaneous power (p-q) theory has been used to determine the suitable current reference signals. The simulation results show that the new control method using PSO approach is not only easy to be implanted but also very effective in reducing the unwanted harmonics and compensating reactive power. The studies carried out have been accomplished using the MATLAB Simulink Power System Toolbox.