The purpose of this paper is to derive a systematic procedure to decide the optimal location and size of compensation shunt capacitors for distribution systems with harmonic distortion. A set of indices determined by the sensitivity of voltage variation, real power loss and harmonic distortion to the reactive power source is used to decide the optimal location of the shunt capacitors. The problem is formulated as a nonlinear programming of the minimization of real power loss and capacitor cost under the constraints of voltage limits and total harmonic distortion. A practical power system is selected for computer simulation to test the efficiency of the proposed method. It is found that both the system loss and harmonic distortion can be reduced very effectively by this method.