A differentiation based control method for a shunt active power filter is used in this paper for functioning in the presence of grid voltage distortion and imbalance. To enable the fast and accurate estimation of the variables in the presence of unbalancing or distortion in the grid voltages, a pre-filtering scheme is considered based on the dual second order generalized integrator (DSOGI) approach. The signal recomposition performed by the pre-filter isolates the harmonics from the voltage and current waveforms, and the differentiation FLL (dFLL) is able to estimate the frequency of the waveforms which is used as a feedback for the pre-filter, thus making the system frequency adaptive. The control algorithm is validated with both simulation studies and a hardware prototype of a active power filter carrying out current compensation robustly, demonstrating the speed and accuracy of the system under grid voltage distortions and maintaining less than 5% supply current total harmonic distortion THD as dictated by IEEE Std. 519-2014.