As the widely use of the non-linear equipment and distribution generation, the harmonic pollution is becoming increasingly severe. Harmonic detection is a major topic in power quality (PQ) analysis. In this paper, an improved algorithm is proposed. This algorithm is based on the five-layer db40 wavelet packet transform (WPT). In order to reduce wavelet aliasing in the middle band, and the Hilbert transform (HT) is used for frequency shift so that the harmonic components are transferred to the marginal band with a better accuracy. Then the shifted signal is decomposed and reconstructed by the WPT for high-accuracy detection of the harmonics. Simulation of different algorithms and errorSanalysisSare also given in this paper. The results show that: this algorithm has a better ability of high-resolution time-frequency analysis and can detect the transientSdisturbance more effectively compared with the traditional Fourier transform, and more accurate than WPT.