The invention discloses a preparation method of a viologen compound, belonging to the field of electrochromic materials. The preparation method comprises the following steps of: (1) dissolving 4, 4'-bipyridyl in excess acetonitrile, dissolving 2-bromobutyl phosphonic acid diethyl ester in the excess acetonitrile, further dripping into a 4, 4'-bipyridyl solution, reacting for 24h, washing, filtering and drying to obtain a (1-(diethyl 2-butylphosphonate)-4, 4'-pyridine) bromide solid; (2) dissolving the prepared solid in methanol, further adding alpha, alpha'-dibromo-p-xylene, stirring at constant temperature, washing, filtering, and performing vacuum drying to obtain a 1, 1'-(1,4-phenylene-bis (methylene))-bis-(1'-(diethyl 2-butylphosphonate)-4,4'-pyridine) tetrabromide solid; and (3) dissolving the prepared product in the step (2) in the methanol, adding concentrated hydrochloric acid, stirring at constant temperature, washing, filtering and drying to obtain 1,1'-(1,4-phenylene-bis (methylene))-bis-(1'-(2-butylphosphonic acid)-4,4'-pyridine) tetrachloride. The viologen compound prepared by the preparation method disclosed by the invention can realize rapid changes in color of the electrochromic materials.