The invention discloses a switching power circuit, which comprises a switching tube, a first resistive divider, a second resistive divider, an inductive component, a freewheel diode, a load unit, a load current detection unit, a comparator, a D latch, an analogue-to-digital converter, a digital-to-analogue converter, a pulse width modulation (PWM) operating mode gate driving voltage generation unit, a first amplifier, a PWM comparator, a pulse frequency modulation (PFM) control unit, a first either-or selector, a second either-or selector, a digital logic unit and a gate driving unit. When a PFM control mode is adopted, the voltage of the switching tube is regulated according to a load to reduce power consumption in a light load condition and improve energy transmission efficiency; and in addition, in the light load condition, the gate driving voltage and switching duty cycle of the switching tube are reduced, so that the power consumption is simultaneously reduced, and the shortcoming that output power is regulated only dependent on the duty cycle of the switching tube to narrow the variation range of the duty cycle and further retard the sudden change of the load and cause large output ripples during mode switching is overcome.