<span>Due to the increasing number of distributed generation units being used in remote regions, the need for reliable and flexible operation of these systems has led to the development of microgrid technology. When a microgrid operates in an autonomous mode, it can experience unpredictable loads and other factors that can affect its operation. An optimal control mechanism is required to maintain the system's stability. Hence, in this paper optimal control strategy of autonomous microgrid for power quality improvement is presented. A test case of single phase 3.5 kW photovoltaic (PV) system based autonomous micro grid is considered. Particle swarm optimization (PSO) and Harris hawks optimization (HHO) optimal control strategies are implemented under standard test case and variable test cases. In all the cases </span><span lang="EN-IN">PV mean voltage-</span><span>Vmpv (V), </span><span>PV mean current</span><span>-</span><span>Impv (A), </span><span>RMS voltage-</span><span>Vrms (V), </span><span>RMS current-</span><span>Irms (A), </span><span>mean PV power-Ppv </span><span>(W), </span><span>autonomous grid power-</span><span>Pg (W)</span><span>, efficiency (%), total harmonic distortion (THD) (%), inverter losses (%) are evaluated. In all the cases HHO optimal control strategy for autonomous microgrid exhibits the best performance in comparison with PSO optimal control strategy. The inverter efficiency is improved, inverter losses are reduced and the THD is improved.</span>