SummaryIndium nitrate/polyvinyl pyrrolidone (In(NO3)3/PVP) composite nanofibers were synthesized via electrospinning, and then hollow structure indium oxide (In2O3) nanofibers were obtained through calcination with PVP as template material. In situ polymerization was used to prepare indium oxide/polyaniline (In2O3/PANI) composite nanofibers with different mass ratios of In2O3 to aniline. The structure and morphology of In(NO3)3/PVP, In2O3/PANI composite nanofibers and pure PANI were investigated by scanning electron microscopy (SEM), Fourier transform infrared spectroscopy (FTIR), X-ray diffraction (XRD), transmission electron microscopy (TEM) and current–voltage (I–V) measurements. The gas sensing properties of these materials towards NH3 vapor (100 to 1000 ppm) were measured at room temperature. The results revealed that the gas sensing abilities of In2O3/PANI composite nanofibers were better than pure PANI. In addition, the mass ratio of In2O3 to aniline and the p–n heterostructure between In2O3 and PANI influences the sensing performance of the In2O3/PANI composite nanofibers. In this paper, In2O3/PANI composite nanofibers with a mass ratio of 1:2 exhibited the highest response values, excellent selectivity, good repeatability and reversibility.