A polyaniline/silica (PANI/SiO2) nanocomposite was electrodeposited on the surface of a stainless steel wire and applied for the extraction of linear alkyl benzenes (LABs) with headspace solid-phase microextraction (HS-SPME) method followed by GC-FID quantification. The structure and morphology of the synthesized sorbent was characterized using scanning electron microscopy (SEM) and Fourier-transform infrared spectroscopy (FT-IR) techniques. Response surface methodology (RSM) involving central composite design (CCD) was employed to evaluate the important experimental variables. Under the optimal conditions, linear dynamic ranges (LDRs) were in the range of 0.05-12µg mL− 1 for Φ-C11 and Φ-C13, 0.02-12µg mL− 1 for Φ-C12 and Φ-C14 with acceptable linearity greater than 0.99. The limits of detection (LODs) were found to be 0.4–0.9 ng mL− 1. The developed HS-SPME-GC-FID method was successfully applied for the extraction and determination of LABs in water and wastewater samples.