Here, we demonstrate the fabrication of 3D porous carbon scaffolds with tunable pore sizes that are comparable to the sizes of bacterial cells for their effective confinement. We utilized the sphere template method to fabricate the 3D porous carbon scaffolds with excellent pore arrangements and enlarged interconnected areas among the pores. The proposed 3D porous carbon scaffolds trapped about 40 times higher densities of Escherichia coli DH5 alpha than conventional 3D porous reticulated vitreous carbon (RVC) scaffolds. Moreover, the proposed porous scaffolds effectively restrain the detachment of the attached cells from the scaffolds because of their geometries, thereby maintaining about 75% of the initial cell densities under repeated washing, whereas almost all the cells were washed away from the conventional 3D porous RVC scaffolds. This effective confinement of bacterial cells will assist in significantly improving the performance of cell-based biological applications. (c) 2018 Elsevier Ltd. All rights reserved.