Today, advanced technologies are used for the reliable operation of power systems. In order to access a reliable and practical function in the systems, it is necessary to use precise control systems with higher efficiency in the systems to minimize the problems of the distribution system. Devices that are made on the basis of power electronics have wide applications in power systems today. These devices, which are called FACTS devices, provide the possibility of improving energy transmission with the least investment cost, as well as quick control of power system problems. FACTS devices are placed in series, parallel or series-parallel transmission lines and control the operation of distribution systems in permanent states as well as the dynamic behavior of the system in transient states. FACTS devices are an effective method to solve the problems and limitations of lines. Transmission and replacement networks are used to create new lines in the network. From the point of view of power distribution control, FACTS controllers can be placed anywhere in the transmission line, but the elements are most effectively used when they are placed at the most critical point. Unified Power Flow Controller (UPFC) is one of the most important FACTS devices that can improve parameters. The quality of power used in the power system depends on the effect of this controller in improving the loss reduction, reducing the total harmonic distortion (THD), and removing the clogged lines to their proper location in the power system. This device is capable of all different effective parameters at a time. These parameters usually include voltage, impedance, and phase. This paper uses a new sensitivity analysis index to determine the optimal size and location of the UPFC to improve the power quality parameters of the distribution system. The proposed method is evaluated on the IEEE 14-bus network in the Simulink environment of MATLAB software. Finally, according to the simulation results and the results obtained from the base network, it is determined that using the proposed sensitivity analysis index in UPFC location, losses Network, total harmonic distortions (THD) and eclipses Network lines are much improved. The results indicate that the proposed method has provided a good answer to determine the optimal size and location of UPFC to improve power quality parameters. Using the results of the sensitivity analysis method, the best place to install UPFC in the power grid, mode number 6 between buses 2 and 11 is obtained. and The amount of network power losses after sensitivity analysis, compared to the base network Active losses of about 55% and reactive losses of about 11% deceased, Due to the circular structure of the network, the current passing through the lines is different depending on the amount of load in the bases near that line, and with the presence of UPFC, the network is optimized and the current passing through the lines is also reduced. 4) Percentage of total harmonic distortion (THD) mains voltage before the presence of UPFC is about 27.12%, which after installation in the 6th place with a maximum size has been reduced to about 11.11%.