The invention belongs to the technical field of electrode base materials, and provides a preparation method of titanium foam. The method comprises the steps that coke is adopted as a pore forming agent and mixed with titanium powder to be sintered, the pore forming agent is removed, and the titanium foam is obtained, wherein the volume ratio of the coke to the titanium powder is (0.5-2):1, the grain size of the coke is 1-6 mm, the sintering temperature is 1,400-1,600 DEG C, and the grain size of the titanium powder is 400 meshes. The preparation method specifically comprises the following steps that S1, the coke and the titanium powder are compacted after being mixed to obtain a mixed sample; S2, the mixed sample is sealed, vacuumizing is performed repeatedly, argon is introduced till foreign gas is exhausted; S3, the temperature is increased to 1,400-1,600 DEG C, and sintering is performed; and cooling is performed to the room temperature to obtain a titanium foam midbody; S4, the midbody is placed into a coke gasification small fixed bed reaction device, the temperature is increased to 1,100 DEG C, CO2 is introduced with the flow being 400-600 ml/min, the reaction is performed for a period of time, heating is stopped, cooling is performed to reach the room temperature. According to the technical scheme, the prepared titanium foam is adopted as an anode, electro-catalysis treatment is performed on the coked wastewater, the number of active loci is large, and the degradation efficiency is high.