Heterocyclic aromatic hydrocarbons are concerned pollutants with carcinogenic toxicity, which exist universally in various environmental matrices and have great harm to environmental and human health. In present work, magnetic resorcinol-formaldehyde composites (Fe3O4@SiO2@R–F) were fabricated via aldol condensation reaction under alkaline condition. The prepared magnetic materials were examined and analyzed with Fourier transform infrared spectroscopy and other related instruments. The Fe3O4@SiO2@R–F composites were utilized to develop an efficient magnetic solid phase extraction (MSPE) method for extracting six heteropolyclic aromatic hydrocarbons from environmental water samples including carbazole (CB), 7-methylquinoline (7-MQL), 9-methylcarbazole (9-MCB), dibenzothiophene (DBT), 4-methyldibenzothiophene (4-MDBT), and 4,6-dimethyldibenzothiophene (4,6-DMDBT). The analytes were analyzed by high performance liquid chromatography-ultraviolet variable wavelength detector (HPLC-VWD). The main factors affecting MSPE were optimized. With the optimal parameters, 9-MCB and 4-MDBT have good linearity over the concentration range of 0.1–300 μg L−1, and 7-MQL, CB, DBT and 4,6-DMDBT have good linearity over the concentration range of 0.5–300 μg L−1. The limits of detection were over the concentration range of 0.012–0.031 μg L−1. This method was successfully employed to measure real waters, and the spiked recoveries ranged from 89.4% to 99.9%. The results confirmed that the developed method was reliable, robust and could be employed as a usefully alternate way for analyzing such pollutants in waters.