We describe an automatic method to detect formaldehyde (FA) in some fermented foods. This method is based on derivatisation with 2,2,2-trifluoroethylhydrazine (TFEH) and consecutive headspace solid-phase micro-extraction and gas chromatography-mass spectrometry. FA in food reacted for 30 min at 40 °C with 2,2,2-TFEH in a headspace vial, and the formed FA-TFEH derivative was simultaneously vaporised and adsorbed on 85-μm carboxen–polydimethylsiloxane. Under the established condition, the limit of detection was 0.1 μg kg−1 by using 1.0-g solid food and 1.0-mL liquid food, and the relative standard deviation was less than 10% at FA concentrations between 0.050 and 0.500 mg kg−1. The concentrations of FA in several traditional Korean foods including gimchi, watery radish gimchi, soybean paste, red pepper paste, soy sauce and bean-paste soup were measured. All food samples had detectable levels of FA (0.104–13.05 mg kg−1).