A series of hyperbranched graft copolymers with hyperbranched polyethylenimine (HPEI) as core and hyperbranched polyglycerol (HPG) as shell (HPEI-g-HPG) were used as nanoreactors and stabilizers for the synthesis of CdS quantum dots (QDs). The preparation conditions were optimized to obtain CdS QDs with a stronger fluorescence. Stable CdS QDs could be prepared by using HPEI-g-HPGs or HPEI homopolymer, but not HPG homopolymer. The CdS QDs capped by HPEI-g-HPGs emitted stronger than those capped by HPEI. Moreover, the photoluminescence intensity increased pronouncedly with increasing the HPG shell content of HPEI-g-HPG stabilizer. The measurements of UV–vis spectroscopy, transmission electron microscopy and dynamic light scattering further verified the formation of CdS QDs. Compared with the CdS QDs capped by HPEI, those capped by HPEI-g-HPGs showed a better storing stability in solution at 4°C. The as-prepared CdS QDs were only stable in the pH range of 7.0–9.0. It was found that increasing the HPG shell content of HPEI-g-HPG stabilizer could effectively raise the selectivity of the as-prepared CdS QDs towards Hg2+. As the ratiometric fluorescence sensors, CdS QDs capped by HPEI-g-HPGs were most sensitive to Hg2+ and the limit of detection was ca. 1.5×10−8M.