Harmonic interference is a major hazard in the current power system that affects power quality. How to extract harmonics quickly and accurately is the premise to ensure the sustainable operation of power system, which is particularly important in the field of new energy power generation. In this paper, a harmonic extraction method based on a time-varying observer is proposed. Firstly, a frequency estimation algorithm is used to estimate the power grid current frequency, which can estimate the frequency in real time. Then, applying the zero-crossing detection method to convert the frequency into a phase variable. Finally, using the phase variable and integral current signal as input, a observer is modeled to extract each order harmonic component. The proposed method is evaluated on a FGPA test platform, which shows that the method can extract the harmonic components of the grid current and converge within 80 ms even in the presence of grid distortions. In the verification case, the relative errors of the 1st, 5th, 7th and 11th harmonics are 0.005%, −0.003%, 0.251% and 0.620%, respectively, which are sufficiently small.