Shunt capacitors installation in distribution systems requires optimal placement and sizing. More harmonics are being injected into distribution systems. Adding shunt capacitors may lead to high distortion levels. The capacitor placement and sizing problem is a nonlinear integer optimization problem, with locations and ratings of shunt capacitors being discrete values. The goal is to minimize the overall cost of the total real power loss and that of shunt capacitors while satisfying operating and power quality constraints. This paper proposes to solve the problem using particle swarm optimization (PSO). A discrete version of PSO is combined with a radial distribution power flow algorithm (RDPF) to form a hybrid PSO algorithm (HPSO). The former is employed as a global optimizer to find the global optimal solution, while the latter is used to calculate the objective function and to verify bus voltage limits. To include the presence of harmonics, the developed HPSO was integrated with a harmonic power flow algorithm (HPF). The proposed (HPSO-HPF)-based approach is tested on an IEEE 13-bus radial distribution system (13-Bus-RDS). The findings clearly demonstrate the necessity of including harmonics in optimal capacitor placement and sizing to avoid any possible problems associated with harmonics.