In this paper, a new optimal two-switching cycle compensation algorithm is proposed to achieve optimal transient performance for DC-DC converters under an input voltage change. Using the principle of capacitor charge balance, the proposed algorithm predicts the optimized two-switching cycle duty cycle series to drive the output voltage back to the steady state when the input voltage changes. Experiments are performed in a 2.5V, 10A, synchronous Buck converter to verify the effectiveness of the proposed algorithm. The results show that using the proposed algorithm, good dynamic performance, including as small overshoot/undershoot and short recovery time is achieved.