As one of the most investigated conducting polymers, polyaniline (PANI) is considered to be of practical use in many applications. In this study, two new ionic liquids, 1-methylimidazolium hydrogen sulfate ([Hmim]HSO4) and 1-methyl-3-n-butylimidazopersulfate ([C4mim]2S2O8), which were synthesized from 1-methylimidazole ([Hmim]), were used as solvent and dopant, oxidizer, respectively, for in situ polymerization of aniline. Because of the application of the unique structure of ionic liquid, we obtained the ionic liquid–doped polyaniline (IL-PANI) with high solubility (25 mg mL−1 in dimethyl sulfoxide (DMSO)). And by adjusting the ratio of [C4mim]2S2O8 to aniline monomer, the preferred PANI nanofibers could be controlled to form a three-dimensional porous structure. It was found that the ion/electron transport channels could be formed inside the 3D structure. Thus, the redox reactions could occur both at the surface and inside the PANI electrode. Electrochemical characterization showed that the fabricated PANI electrode exhibited a specific capacitance of 489 F g−1 at a current density of 0.5 A g−1. Also, the capacity retention rate reached up to 81% after 4000 cycles investigated at 2 A g−1. In addition, a high-energy density of 80.2 Wh kg−1 was measured when [Hmim]HSO4 was used as an electrolyte. Thus, the present work suggested a new strategy for fabricating high-performance PANI electrode for supercapacitor applications.