Ultrasound-assisted headspace solid-phase microextraction (UA-HS-SPME) and hydrodistillation (HD) methods, coupled to gas chromatography-mass spectrometry (GC-MS), were used for the extraction and analysis of volatile compounds from Hypericum perforatum and Hypericum scabrum collected from two different sites in Iran. In the UA-HS-SPME method, various experimental parameters such as the type of fiber coating, sonication time, extraction time, extraction temperature and desorption time were investigated. The highest extraction efficiency was achieved by a 100-µm polydimethylsiloxane (PDMS) fiber. Consequently, 36 compounds were identified in H. perforatum and H. scabrum samples, using the UA-HS-SPME-GC-MS method, of which 14 were the same in both species. On the other hand, 57 compounds of these species were identified by the HD-GC-MS method, of which 21 were the same. The predominant constituents identified using the UA-HS-SPME method in H. perforatum included β-caryophyllene, α-pinene, γ-cadinene, α-selinene, germacrene-D, limonene and myrcene, and in H. scabrum were α-pinene, nonane, β-pinene and limonene. The common constituents identified by the HD-GC-MS method for H. perforatum involved germacrene-D, limonene, β-caryophyllene, α-pinene, β-pinene and germacrene-B, and for H. scabrum were α-pinene, β-pinene, germacrene-D, nonane, limonene and γ-cadinene. The results about the main constituents of the examined species correspond to the findings of other researchers. Additionally, comparing UA-HS-SPME-GC-MS and HD-GC-MS methods showed that the UA-HS-SPME-GC-MS method is much faster and simpler, and it requires much less sample size and lower temperature.