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