This study developed a novel ratiometric electrochemical sensor for detecting formaldehyde content in food. For the first time, we innovatively utilized 4-amino-3-hydrazino-5-mercapto-1,2,4-triazole (AHMT), a traditional colorimetric probe that specifically reacts with formaldehyde, as an electrochemical probe to construct the electrochemical assay. The reaction product of AHMT with formaldehyde exhibits different redox potentials from AHMT, thereby enabling ratiometric detection of formaldehyde. We systematically investigated the electrochemical behavior of AHMT and its reaction product with formaldehyde. Under optimized conditions, this novel ratiometric electrochemical assay demonstrated high sensitivity and selectivity for formaldehyde, with a response linear range of 0.1-20 μM and a detection limit of 21 nM. Additionally, the sensor was successfully applied to detect formaldehyde in various mushrooms and fish, with measured concentrations of 1.34 μg g