An insulating rotary encoder that is stable, precise, simple to assemble, and strong against vibration, comprising: a sealed housing, a main shaft, a metal grating disc sleeving the outer side of the main shaft, and a circuit board disposed inside of the sealed housing. Also provided on the sealed housing is an electrical cable sheath, said electrical cable sheath being provided inside with an electrical cable, one end of the electrical cable being electrically connected to the circuit board. Two bearings sleeve between the outer side of the main shaft and a rack. The outside of the bearing distant from the metal grating disc is provided with a blocking ring, the blocking ring surrounding the outer side of the main shaft. The rack comprises a main rack and a secondary rack that sleeve in sequence the outer side of the main shaft, and a positioning element is provided between the secondary rack and the main shaft. The positioning element is a metal positioning element, and the circuit board is made of an insulating PVC-coated steel material.