In this paper, a novel fluorescent nanoswitch based on carbon dots (CDs) was developed for the sensitive and selective determination of Hg[Formula: see text] and I[Formula: see text]. The CDs were obtained by simple hydrothermal process and had a strong fluorescence emission at 440[Formula: see text]nm. The fluorescence of the CDs can be selectively quenched by Hg[Formula: see text] ion, and then the I[Formula: see text] was added into the system, which can interact with Hg[Formula: see text] and recover fluorescence of the CDs. Under optimal conditions, the quenching fluorescence intensity on addition of Hg[Formula: see text] has obtained a satisfactory linear relationship covering the linear range of 0–50[Formula: see text][Formula: see text]M with the linear relationship ([Formula: see text]), and the limit of detection is 0.047[Formula: see text][Formula: see text]M. The additions of I[Formula: see text] could lead to the fluorescence intensity of the solution of CDs and Hg[Formula: see text] (50[Formula: see text][Formula: see text]M) recover rapidly, which is linearly related ([Formula: see text]) to the concentration of I[Formula: see text] in the range from 0 to 70[Formula: see text][Formula: see text]M, the detection limit for I[Formula: see text] was calculated to be 0.084[Formula: see text][Formula: see text]M. Moreover, the developed method to detect Hg[Formula: see text] and I[Formula: see text] was evaluated in real examples, and the fluorescence switching can sensitively and selectively detect Hg[Formula: see text] and I[Formula: see text] over some potentially interfering ions, the recoveries were up to 97.8–107.0% and 96.7–106.6%, respectively.