Atmospheric acidity is increasingly determined by carbon dioxide and organic acids1–3. Among the latter, formic acid facilitates the nucleation of cloud droplets4 and contributes to the acidity of clouds and rainwater1,5. At present, chemistry–climate models greatly underestimate the atmospheric burden of formic acid, because key processes related to its sources and sinks remain poorly understood2,6–9. Here we present atmospheric chamber experiments that show that formaldehyde is efficiently converted to gaseous formic acid via a multiphase pathway that involves its hydrated form, methanediol. In warm cloud droplets, methanediol undergoes fast outgassing but slow dehydration. Using a chemistry–climate model, we estimate that the gas-phase oxidation of methanediol produces up to four times more formic acid than all other known chemical sources combined. Our findings reconcile model predictions and measurements of formic acid abundance. The additional formic acid burden increases atmospheric acidity by reducing the pH of clouds and rainwater by up to 0.3. The diol mechanism presented here probably applies to other aldehydes and may help to explain the high atmospheric levels of other organic acids that affect aerosol growth and cloud evolution.