The invention relates to a biocide for pipeline cleaning, and a preparation method thereof, wherein the biocide comprises the following raw materials by weight: 20-30 parts of 2,2'-dihydroxy-5,5'-dichlorophenylmethane, 10-20 parts of 2,2-dibromo-3-carbamoylacetonitrile, 5-10 parts of zinc dialkyl dithiophosphate, 5-10 parts of methylene bisstearamide, 1-3 parts of 3,7-dimethyl-2,6-octadiene nitrile, 10-15 parts of boric acid diglyceride sodium monostearate, and 200-300 parts of deionized water. According to the present invention, the biocide can form the protection film on the metal surface, such that the catalytic oxidation effect of the metal can be eliminated, and the surface corrosion and the surface wear on the metal can be prevented; the biocide can reduce the friction between the polymer molecular chains, can improve the lubricity among various raw materials, can reduce the reaction time, and can improve the sterilization and algae-killing effect; and the biocide has the mild odor, can make the treated pipeline maintain the lemon aroma, can label the treated pipeline in the odor manner so as to avoid the multiple treatments within a short time, and can improve the management efficiency and reduce the use cost.