In this paper, yellow fluorescent carbon dots (Y-CDs) were successfully synthesized by carbonization of o-phenylenediamine and p-aminobenzoic acid with hydrogen peroxide. The as-prepared Y-CDs possess excellent photoluminescence, high photostability, good water solubility and are rich in various functional groups on the surface by the analysis of transmission electron microscope, Fourier transform infrared spectrum, X-ray photoelectron spectroscopy, fluorescence spectrophotometer and ultraviolet-visible absorption spectrum. With these superior properties, Y-CDs have been used as sensing probes for the detection of Hg2+ ions and show a high selectivity for Hg2+. There is a good linear relationship between the fluorescence intensity of Y-CDs and the concentration of Hg2+ between 20 μM and 150 μM, and the minimum detection limit reach to 0.12 μM. Furthermore, the detection method was applied to the recovery test of Hg2+ in real water samples and the ideal recovery rate was obtained. Based on above researches, the fluorescent test paper which is convenient to carry is prepared. In order to explore the mechanism of fluorescence quenching, Y-CDs was combined with zeolite imidazole skeleton-8 to synthesize [email protected] composites. After adding Hg2+, the fluorescence of [email protected] was no longer quenched. By analyzing the fluorescence lifetime, UV–vis absorption spectra and Fourier transform infrared spectra of Y-CDs before and after adding Hg2+, the mechanism of fluorescence quenching was finally determined to be static quenching.