A novel and rapid headspace solvent microextraction followed by gas chromatography–mass spectrometry (HSME-GC–MS) for the analysis of the volatile compounds of Foeniculum vulgare Mill is described. HSME parameters including extracting solvent, extraction temperature and time, headspace volume and particle size were optimized. As a result, benzyl alcohol was finally used for the extraction at 70°C for 20min with headspace volume of 12.1ml and particle size of 120 mesh. Under the determined conditions, the powered samples of Foeniculum vulgare Mill were directly applied for the analysis. A comparison of HSME-GC–MS, solid phase microextraction (SPME)-GC–MS and steam distillation (SD)-GC–MS methods was made and showed that the HSME-GC–MS method was simple, inexpensive and effective and can be used for the analysis of volatile compounds in traditional Chinese medicines (TCMs).