The invention belongs to the technical field of preparation of electrochemical sensors, and specifically discloses an electrochemical sensor with self-cleaning ability. The electrochemical sensor comprises an electrode core and a novel composite material based on MTOF (M refers to a doped metal element), and the composite material is attached to the surface of the electrode core. The preparation method of the sensor is simple, time-saving, low in cost and environmentally friendly. In particular, the residue of polymers and detected substance contained in the sensor and attached to the surfaceof the electrode core after detection can be oxidized under ultraviolet light and visible light conditions, thereby realizing the regeneration and self-cleaning effects of electrochemical sensor undervisible light. An electrochemical sensing platform regenerated under visible light not only reduces the tedious process of electrode polishing and modification, but also saves the cost of modifying materials, and the descaling regeneration of the electrode prolongs the service life of the electrode. The sensor is applied to the simultaneous detection of environmental pollutants, that is, hydroquinone and catechol, the operation is simple and convenient, the selectivity is good, the sensitivity is high, and the detection limit is low.