This study introduces a novel method for harmonic suppression in electrical systems using a shunt hybrid active power filter (APF) with a linear quadratic regulator (LQR) tuned by particle swarm optimization (PSO). The proposed approach significantly enhances the performance of the LQR controller, resulting in reduced harmonic content and improved signal quality, while being more efficient and time-saving compared to traditional trial-and-error methods. The simulation results demonstrate that current injection into the network can be reduced by up to 95%, ensuring better power quality in systems with nonlinear loads.