Water-dispersed self-doped sulfonated polyaniline (SPANi) and self-doped carboxylated polyaniline (CPANi) were prepared by the copolymerization of aniline with m-aminobenzenesulfonic acid and m-aminobenzoic acid, respectively, and were identified by UV-vis spectroscopy, Fourier transform infrared spectroscopy, X-ray photoelectron spectroscopy, X-ray diffraction, and scanning electron microscopy. The resultant SPANi and CPANi nanofibers were used as anticorrosion pigments for water epoxy coatings (EP). The corrosion resistance was compared using anticorrosive studies in 3.5 wt% NaCl solution using electrochemical impedance spectroscopy (EIS), polarization curves (Tafel), and a neutral salt spray (NSS) test. Polarization tests showed that the corrosion potential of SPANi/EP coating increased compared with CPANi/EP. EIS tests after 40-day immersion. This behavior further confirmed that the impedance modulus and coating resistance of SPANi/EP increased by three orders of magnitude compared with EP, which were two orders of magnitude higher than that of polyaniline (PANi)/EP and one order of magnitude higher than that of CPANi/EP.