The effects of recipe compositions in terms of leavening agent (ammonium and sodium bicarbonates) and sugars (sucrose and glucose), and baking conditions (temperature and time) on HMF formation in cookies were studied. Five recipes were prepared by varying the types of leavening agent and sugar. The cookies were baked at different temperatures (180, 200, 210 and 220 degrees C) for different time (10, 15, 20 and 25 min) to monitor physical and chemical changes in cookie composition in terms of water activity, pH, surface browning, sugar decomposition, and hydroxymethylfurfural (HMF) formation. Decreasing moisture to a level under a water activity of 0.4 appeared as the critical point in baking where the rate of HMF formation drastically increased after this point. After this stage, sucrose decomposed very rapidly if ammonium bicarbonate was used as the leavening agent at temperatures greater than 200 degrees C. Replacing ammonium bicarbonate with sodium bicarbonate maintained pH of cookies ranging between 9.0 and 10.0 during baking, which limited the decomposition of sucrose.