The selective photocatalytic reduction of CO2 to CO by using three-dimensional hexagonal and mesoporous graphitic carbon nitride (denoted as 3D H-g-C3N4-T) which are prepared via a microwave-assisted route is reported. The physicochemical and optical properties of prepared photocatalysts are characterized by various analytic tools and spectroscopies. Notably, the structure and morphology of 3D H-g-C3N4-T can be regulated by microwave-assisted hydrothermal temperatures (130–190 °C) in an ammonia solution. The obtained g-C3N4 and 3D H-g-C3N4-T are used as photocatalysts in the CO2 photoreduction under the visible-light irradiation. Among these photocatalysts, the 3D H-g-C3N4-130 shows the superior CO yield which is ca. 2.6-fold higher than the pristine g-C3N4. The formation of 3D hexagonal prisms with mesoporous structure observed for 3D H-g-C3N4-130 is responsible for the promoted visible-light absorption, greater surface area and abundant amino functional groups boosting the selective CO2-to-CO conversions. The present work demonstrates a time and energy-efficient route to prepare unique 3D g-C3N4 which may offer the possible applications in the solar photoreduction of CO2.