In this article, proportional resonant (PR) controller-based pulse width modulation (PWM) current control for three-phase, three-leg SAPF with the optimized dc-link controller is implemented to compensate for current harmonics produced by nonlinear loads. The optimization of the dc-link voltage regulator is implemented using Bat Algorithm (BA). The stability of the current controller with the proposed system with a mathematical model is evaluated in the time and frequency domain. Instantaneous real and reactive power theory (pq-theory) is applied for reference currents generation. Simulation of the proposed controller is performed in MATLAB/Simulink environment. The controller is implemented in FPGA platform and the results of simulation are verified with the experimental prototype. The optimized dc-link results in the improved performance of SAPF. The new dimension of the PR controller in a grid-connected system for harmonic regulation is implemented and validated with experimental results. The objective of reduced current harmonics with a minimum per phase fundamental current and unity power factor at the point of common coupling is achieved. © 2020 John Wiley & Sons Ltd