Although formaldehyde has been widely used in industry, the excessive or residual formaldehyde has been proven to cause irreversible harm to human beings due to its high toxicity. To solve this problem, we studied oxalyldihydrazide as an analytical reagent to determine formaldehyde by ultraviolet and visible (UV-vis) spectrophotometry. In this study, hydrazine compounds with –NH–NH2 structures can react with formaldehyde to form hydrazone (including –NH–N=CH–), water is the only by-product. Therefore, oxalyldihydrazide can not only react with formaldehyde but also sense its analogs such as acetaldehyde, acetone, and benzaldehyde in solution, and detect them by UV-vis spectrophotometry at 220 nm, 226 nm, 262 nm, and 257 nm respectively. Among them, the limit of detection (LOD) of formaldehyde is calculated to be 0.03 ppm (LOQ = 0.03 ppm) with the relative standard deviation (RSD) of 1.58%. Meanwhile, the above-mentioned method can be used for detecting formaldehyde in clams with excellent selectivity and sensitivity.