The invention relates to a carpet cleaning agent and a preparation method thereof. The carpet cleaning agent comprises the following components in parts by weight: 0.5-0.8 part of N, N-dimethyldodecylamine-N-oxide sol, 0.2-0.6 part of sodium dodecyl benzene sulfonate, 1-3 parts of polyoxyethylene nonyl phenyl ether, 2-4 parts of sodium hydroxide, 0.5-0.8 part of anhydrous sodium acid pyrophosphate, 0.1-0.4 part of butyl p-hydroxybenzoate, and 90.4-95.7 parts of water. The carpet cleaning agent is strong in decontamination capability, obvious in cleaning effect, nontoxic and innocuous; anhydrous sodium acid pyrophosphate is cooperatively used with a surfactant , so that detergency is increased, and the dirt after washing and the cleaning agent adhered to fiber are powdered and convenient to adsorb and remove by a dust collector, and secondary pollution is avoided; butyl p-hydroxybenzoate is used to replace sodium benzoate, sterilization effect is good and performances are stable; and additionally, the preparation method of the invention is simple and cost is low.