The invention relates to a set top box with a dustproof function, the set top box comprises a main body and a plurality of plugging ports, the set top box also comprises a dustproof mechanism and a dedusting mechanism, the dustproof mechanism comprises a fixed magnetic strip and a plurality of dustproof assemblies, and each dustproof assembly comprises a rotating unit, a dustproof plate, a transmission disc, a first bearing, a transmission shaft and a transmission unit. The dust removal mechanism comprises a driving assembly, a connecting assembly, a fixing ring, two fixing rods and two dust removal assemblies, each dust removal assembly comprises a dust removal rod, a rolling ball, a first spring and two telescopic rods, the set top box with the dustproof function realizes the function of shielding the insertion port through the dustproof mechanism, so that dust in air cannot be attached to the insertion port, the phenomenon of poor plugging is avoided, and the reliability of the equipment is improved. Through the dust removal mechanism, the function of removing dust above the main body is achieved, the situation that the heat dissipation effect of the main body is affected due to dust accumulation above the main body is prevented, and then the reliability of the equipment is improved.