Formaldehyde is a carcinogenic compound that was employed as fungicide in the past. Despite its disuse, some foods such as mushrooms naturally produce formaldehyde, showing the importance of its determination. In this work, a mechanized flow system based on solenoid valves is proposed for spectrophotometric formaldehyde determination in mushrooms. The analyte was extracted from fresh and dried mushrooms samples by steam distillation with deionized water in the presence of phosphoric acid. The determination was based on the reaction between formaldehyde and acetylacetone in presence of ammonium acetate (Hantzsch reaction), leading to the formation of 3,5-diacetyl-1,4-dihydrolutidine (DDL, λ max = 412 nm). Linear response from 0.2 to 7.0 mg L -1 was achieved, with detection limit estimated at 0.02 mg L -1 (99.7% confidence level). Coefficient of variation and sample throughput were 1.1% (n = 15) and 17 h -1 , respectively. Per determination, 11 mg of acetylacetone and 30 mg of ammonium acetate were consumed, generating 4.2 mL of waste. The procedure was applied to formaldehyde determination in fresh and dried shiitake, and fresh shimeji, and the results agreed with those attained by reference method at the 95% confidence level.