Polyaniline (PANI) nanofibers were synthesized by interfacial polymerization at 20 °C. The ultraviolet–visible–near-infrared light (NIR) absorption spectra indicated two absorptions at 450 nm and 848 nm, which exhibited the NIR-absorbing characteristic of PANI. The photothermal conversion temperature of PANI nanofibers increased with the NIR power density of 808 nm. The nanofibers were added to the epoxy resin to prepare NIR-induced shape memory and self-healing coating. The shape memory effect of the composites was measured via NIR irradiation of 2 W cm−2 808 nm. The surface morphologies of the scratched and healed coatings were investigated by optical stereomicroscopy. The healing performance of the intact, damaged, and healed coatings was also evaluated by linear sweep voltammetry and polarization curves. Results indicated that the shape recovery time of the composite decreased as PANI content increased. The composite with 5 wt% PANI exhibited the best shape memory effect and multiple self-healing performances. Moreover, PANI nanofibers improved the protection performance of the epoxy resin coatings. The electrochemical results indicated that the coating with 5 wt% PANI had good self-healing performance when the scratched area was irradiated by NIR. This finding was attributed to the photothermal conversion effect and passivation function of the PANI nanofibers.