The detection of toxic metals is indispensable for water safety. In this paper, a small molecule of aggregation-induced emission (AIE) with barbiturate group was synthesized. It combined with mercury ions to form a stable metal complex so as to enhance the color of the solution to achieve the visualization of ion detection. The fluorescent molecule showed good selectivity and anti-interference ability and had a low detection limit (DL = 22.27 nM) for mercury ion.