Formaldehyde (FA) is a carcinogen that is not only widespread in the environment, but is also produced endogenously by metabolic processes. In organisms, FA is converted to formic acid in a glutathione (GSH)-dependent manner by alcohol dehydrogenase 5 (ADH5). The abnormal accumulation of FA in the body can cause a variety of diseases, especially cognitive impairment leading to Alzheimer's disease (AD). In this study, melatonin derivative 6a (MD6a) markedly improved the survival and chemotactic performance of wild-type Caenorhabditis elegans exposed to high concentrations of FA. MD6a lowered FA levels in the nematodes by enhancing the release of covalently-bound GSH from S-hydroxymethyl-GSH in an adh-5-dependent manner. In addition, MD6a protected against mitochondrial dysfunction and cognitive impairment in beta-amyloid protein (Aβ) transgenic nematodes by lowering endogenous FA levels and reducing Aβ aggregation in an adh-5-dependent manner. Our findings suggest that MD6a detoxifies FA via ADH5 and protects against Aβ toxicity by reducing endogenous FA levels in the C. elegans AD models. Thus, ADH5 might be a potential therapeutic target for FA toxicity and AD.