Patients with type 2 diabetes mellitus (T2DM) often develop cognitive impairments and have an increased risk of developing Alzheimer's disease. Hyperglycemia is a major characteristic of T2DM, but how elevated glucose levels lead to cognitive decline remains elusive. Here, we report that patients with T2DM and mutations in the formaldehyde (FA)-degrading enzyme aldehyde dehydrogenase 2 ( ALDH2) gene had higher levels of FA and more severe dementia. Injection of FA induced hyperglycemia and cognitive deficits in rats. Ablation of gene expression of ALDH2, the main enzyme to oxidize FA, resulted in abnormally high levels of hippocampal FA, leading to hyperglycemia and cognitive impairments as well as potentiating streptozotocin-induced diabetes development in ALDH2 knockout mice. We found that FA interacts with insulin to form FA-insulin adducts, and these FA-insulin adducts caused insulin deficiency, contributing to memory decline in diabetic rodent models. Reduction of FA by transgenic overexpression of human ALDH2 attenuates hyperglycemia and alleviates cognitive deficits in diabetic mouse models. These findings suggest that excess FA plays a critical role in mediating diabetes-related dementia. Targeting FA and its metabolizing enzyme ALDH2 may be a valid approach for preventing and treating dementia in diabetes mellitus.-Tan, T., Zhang, Y., Luo, W., Lv, J., Han, C., Hamlin, J. N. R., Luo, H., Li, H., Wan, Y., Yang, X., Song, W., Tong, Z. Formaldehyde induces diabetes-associated cognitive impairments.