A family of nanostructured polyaniline (PANI) materials including polystyrene (PS)/PANI core/shell particles, PANI hollow spheres, PANI/PS nanocomposite and nanoporous PANI, were conveniently prepared by surface charge control of PS nanoparticle templates which resulted in different polymer growth mechanisms when PANI was electropolymerized around the templates.