The most difficult aspect of optimizing a wind farm is creating an accurate wind farm model, especially if the farm is connected to the grid. The inconsistency and unpredictability of wind speeds exacerbates this issue. When dealing with wind farms, it is possible that the reactive power addition capabilities of individual wind turbines are insufficient to meet network requirements. This is due to cable losses and line losses between the wind farm and PCC. This study employs a doubly fed induction generator (DFIG) and a Static Synchronous Compensator (STATCOM) compensator to keep the output voltage amplitude more constant. Using two PI controller loops, the STATCOM will generate reactive (capacitive) power if the DFIG voltage is lower. The STATCOM will then absorb reactive (inductive) electricity if the DFIG system voltage is greater. STATCOM's ability to regulate the flow of reactive power can increase the network's stability. By optimizing the network's reactive power, the power factor is increased and stabilized up to 0.99. In addition, the system's harmonics never exceed the 5% limit specified by the IEEE 519-1992 standard.