Branched AuNPs usually have two or more local surface plasmon resonance (LSPR) absorption bands due to their structural anisotropy, and the LSPR performance is more sensitive to the changes of environmental refractive index than that of spherical AuNPs. The design and preparation of branched AuNPs as colorimetric probes is expected to improve the selectivity and sensitivity of detection of targets. In this paper, branched AuNPs were innovatively synthesized via hyperbranched polyethylenimine (HPEI) fabricated and capped AuNPs as seeds and cetyltrimethylammonium bromide (CTAB) as template agent. The branched AuNPs were characterized by TEM, DLS, zeta potentials and UV–vis spectra. Using the branched AuNPs as a colorimetric probe, the detection system for Hg2+ and Ag+ showed bright color changes from blue to orange and blue to green based on the morphological evolution of branched AuNPs. The branched AuNPs could selectively detect Hg2+ and Ag+ at concentrations as low as 77 and 140 nM, respectively. Moreover, this unusual colorimetric method has been successfully used in real water samples and has great potential as a simple, rapid, sensitive and selective method for the detection of Hg2+ and Ag+.