Purpose This paper aims to investigate effect of porous polystyrene microspheres encapsulated inhibitor on the protection performance of epoxy resin coating. Design/methodology/approach Porous polystyrene (PS) microspheres were synthesized by soap-free emulsion polymerization. The morphology of microspheres was observed by scanning electron microscopy and transmission electron microscopy. Corrosion inhibitor benzotriazole was encapsulated into porous PS microspheres. The protection performance of epoxy resin coating with different contents of PS microspheres was tested by polarization curve. Findings The findings of electrochemical impedance spectroscopy and scanning vibrating electrode technique showed that addition of corrosion inhibitor to porous PS microspheres further improved the protection performance of the coatings. Practical implications Porous PS microspheres could be used as nanocontainer to encapsulate corrosion inhibitor. Originality/value Addition of porous PS microspheres with corrosion inhibitor improved the protection performance of the coatings.