An active power filter includes an energy storage capacitor, an inverter, a filtering circuit and a controller. The inverter is controlled to act as a virtual resister at a fundamental frequency for compensating for the power loss of the active power filter, to act as a virtual capacitor at a fundamental frequency for compensating for a fundamental reactive power of the load, and/or to generate a harmonic current for suppressing the harmonic currents of specific orders of the load.