Nitrogen and sulfur codoped carbon dots (NSCDs) were synthesized via a one-pot hydrothermal method, and citric acid, ethylenediamine, and methyl blue were used as precursors. The obtained NSCDs were spherical with an average size of 1.86 nm. The fluorescence emission spectra of the NSCDs were excitation independent and emitted blue fluorescence at 440 nm with an excitation wavelength at 350 nm. The quantum yield of the NSCDs was calculated to be 68.0%. The NSCDs could be constructed as fluorescent probes for highly selective and sensitive sensing mercuric (Hg2+) and hypochlorite (ClO−) ions. As the addition of Hg2+ or ClO− ions to the NSCDs, the fluorescence intensity was effectively quenched due to dynamic quenching. Under the optimal conditions, the linear response of the fluorescence intensity ranged from 0.7 μM to 15 μM with a detection limit of 0.54 μM and from 0.3 μM to 5.0 μM with a limit of detection of 0.29 μM for Hg2+ and ClO− ions, respectively. Finally, the proposed method was successfully used for quantifying Hg2+ and ClO− ions in spiked tap water samples.