Nanoporous p-type semiconductor thin films prepared by a simple solution-based process with appropriate thermal treatment and three-dimensional (3D) p-n junction solar cells fabricated by depositing n-type semiconductor layers onto the nanoporous p-type thin films show considerable photovoltaic performance compared with conventional thin film p-n junction solar cells. Spin-coated p-type Cu2ZnSnS4 (CZTS) thin films prepared using metal chlorides and thiourea show unique nanoporous thin film morphology, which is composed of a cluster of CZTS nanograins of 50-500 nm, and the obvious 3D p-n junction structure is fabricated by the deposition of n-type CdS on the nanoporous CZTS thin films by chemical bath deposition. The photovoltaic properties of 3D p-n junction CZTS solar cells are predominantly affected by the scale of CZTS nanograins, which is easily controlled by the sulfurization temperature of CZTS precursor films. The scale of CZTS nanograins determines the minority carrier transportation within the 3D p-n junction between CZTS and CdS, which are closely related with the photocurrent of series resistance of 3D p-n junction solar cells. 3D p-n junction CZTS solar cells with nanograins below 100 nm show power conversion efficiency of 5.02%, which is comparable with conventional CZTS thin film solar cells.