The high performance detection of heavy metal ions in crucial water sources is of great significance to protect human health and life safety. Herein, a novel ratiometric detection system towards trace Cd(II) and Pb(II) has been established by utilizing in-situ bismuth modified nitrogen rich porous carbon/boron doped diamond (Bi/NC/BDD) composite electrode. Benefiting from the interconnected hierarchical micro/mesoporous structure and N-embedded partially graphitized carbon matrix of NC modifier, as well as the formation of Bi-alloy, an excellent sensitivity with low limit of detection (LOD, 0.24 μg L−1 for Cd(II) and 0.37 μg L−1 for Pb(II)) is realized. Moreover, the built-in normalization function of Bi(III) reference signal effectively improves the reliability and reproducibility of detection results. This work provides an important guidance for the development of quality environmental monitoring electrodes.