The invention relates to a method for preparing sunitinib. The method comprises the steps of dissolving 5-fluoro-1,3-indoline-2-ketone and N-(2-diethylin ethyl)-2,4-dimethyl-5-formyl group-1H-pyrrole-3-formamide into methylbenzene, then carrying out backflow reaction for 2.5-3.5 hours with piperidine as a catalyst, cooling to room temperature, carrying out suction filtering, and washing and drying filter cakes obtained by suction filtration through petroleum ether, so as to obtain the sunitinib, wherein the N-(2-diethylin ethyl)-2,4-dimethyl-5-formyl group-1H-pyrrole-3-formamide is prepared through hot melting and decarboxylation of 3,5-dimethyl-1H-pyrrole-4-carbethoxy-2-carboxylic acid, Vilsmeier-Haack formylation, hydrolysis reaction and amidation. According to the method, an intermediate of the sunitinib is prepared and synthesized through a solvent-free method, so that the overall yield of the sunitinib is greatly increased; in addition, the technology for elementary reaction is optimized; furthermore, the raw materials are easy to obtain, and by optimizing all reaction steps in the synthetic process, the elementary reaction yield of each step is increased, the total yield of the sunitinib is increased, and thus the synthetic cost of the sunitinib is lowered.