The Microgrid is a combination of the distributed generation (DG) systems that deliver power to its local networks. The DG system constitutes non-conventional sources such as wind turbine, fuel cell, battery, and Solar. By connecting microgrid to the non-linear loads, it generates harmonic current into the system, which disturbs the sinusoidal waveform and power factor. The power quality compensator is used for improvement of the reliability and efficiency of the system. In this paper, first power quality issues are analyzed by connecting loads. As the system is connected to load it disturbs the sinusoidal waveform by introducing harmonics. To reduce these harmonics, passive filters are used. But due to the certain drawbacks such as complication in design and huge size of filter shunt active power filter (SAPF) is introduced in this system. These SAPF is controlled by an instantaneous power theory, which works as on line power quality analyzer and limits THD according to the IEEE 519-1992 standard. Depending on the power requirement of the nonlinear load, the proposed control for SAPF allows balanced line with near sinusoidal current and also maintains unity power factor. The presented model is simulated in the Matlab/ simpower environment and results are validated. © 2021, Springer Nature Singapore Pte Ltd.