In this paper, carbon quantum dots (N-S-CDs) containing sulfur and nitrogen were synthesized using citric acid and thiourea. The average particle size of N-S-CDs is 8 nm. The N-S-CDs surface contains various of functional groups, which has good water solubility. The fluorescence quantum yield of N-S-CDs is as high as 36.8%. N-S-CDs emits strong blue fluorescence in aqueous solution and has good photostability in neutral and alkaline NaCl solution. N-S-CDs has unique selectivity and high sensitivity to Fe3+ and Hg2+ ions, and the lowest detection limits are 1.4 μM and 0.16 μM, respectively. Under the interference of other metal ions, Fe3+ and Hg2+ ions can still effectively and stably quench the fluorescence of N-S-CDs. In addition, in the detection of actual samples, N-S-CDs can effectively detect Fe3+ and Hg2+ ions in tap water and lake water.