Highly crystallized polyaniline (PANI) nanofibers were synthesized by oxidative polymerization of aniline in the presence of sodium alginate as a soft template in HCl and ammonium peroxydisulfate (APS) acting as an oxidizing agent. Sodium alginate, in presence of a protonic acid like HCl, formed hydrogen bonds with anilium ions or oligomers. The formed hydrogen bonds provide the driving force to form PANI nanofibers. The nanofibers were separated from the alginate gel by degelling with ammonium hydroxide and during degelling emeraldine salt was converted into emeraldine base form. The polymerized PANI was characterized using ultraviolet (UV)-visible spectroscopy, Fourier transform infrared spectroscopy (FTIR), X-ray diffraction (XRD), and scanning electron microscopy (SEM). UV and FTIR spectra showed that the presence of sodium alginate had no effect on the electronic state and backbone structures of the resulting PANI products. It was evident from the XRD analysis that the obtained PANI nanofibers exhibit higher crystalline order. SEM micrographs showed that PANI nanofibers were just like a mat of interwoven twisted nanofibers. After magnification of the SEM image, it was found that most of the nanofibers were interconnected to form ramose structures rather than isolated nanofibers. © 2011 Wiley Periodicals, Inc.