Abstract Aiming at the vibration brought by the non-rigid behaviour of the leg mechanism during walking, a vibration suppression method based on optimal control for humanoid robot walking is proposed. First, the vibration is modelled and added to the original robot dynamics model. Then based on the extended dynamics model, the preview control method is used to generate a control trajectory subject to the COM (Center of Mass) acceleration constraints, which serves as the initial solution of the optimal control problem. Starting from this initial solution, the optimal control problem is solved by iteration method, yielding an optimal control trajectory which suppresses the vibration in a feed forward manner. Finally, the method is validated through contrast experiments on the humanoid robot Kong.