A highly sensitive and selective chemosensorLexhibited well-defined naked-eye visible color changes from yellow to pink, which was used for Hg2+detection in acetonitrile. For the selective recognition of Hg2+ions, it forms a 1 : 1 stoichiometric complex involving naphthoquinone hydroxyl and diaminomaleonitrile nitrogen functionalities.