Polyaniline nanofibers were prepared through the in situ oxidative polymerization method and were used for the detection of aromatic organic compounds (AOCs). The nanofiber structures were characterized by scanning electron microscopy, infrared spectroscopy, UV–vis spectroscopy, and so on. The polyaniline nanofibers had diameters of 40–70nm and a length of several hundred nanometers. Polyaniline was highly doped by HCl. The sensor response to AOC was investigated in several hundred ppm ranges. The sensor showed an increase in conductivity, and the maximum response measured at 1000ppm was several tens of percent. The interaction mechanism was discussed through X-ray photoelectron spectroscopy study.