Herein, novel photoactive materials, nitrogen-doped porous carbon-ZnO (NPC-ZnO) nanopolyhedra, were prepared by direct carbonization of zeolitic imidazolate framework (ZIF)-8 nanopolyhedra in a nitrogen atmosphere. The morphology, structure, and photoelectrochemical (PEC) properties were characterized by scanning electron microscopy, transmission electron microscopy, X-ray photoelectron spectroscopy, Raman spectroscopy, nitrogen adsorption-desorption method, and PEC methods. The results showed that the obtained NPC-ZnO nanopolyhedra had a rhombic dodecahedron morphology with uniform particle size of about 100 nm and a high surface area of 609.2 m g. Under visible-light irradiation, the NPC-ZnO nanopolyhedra showed better PEC performance than ZnO nanorod and the ZIF-8 nanopolyhedra in aqueous media with dissolved oxygen and ascorbic acid. Taking alkaline phosphatase (ALP) as a model, a NPC-ZnO nanopolyhedra-based PEC sensor was developed and showed good performance for ALP assay with a wide linear response range from 2 to 1500 U L and a low detection limit of 1.7 U L. Moreover, the PEC sensor possessed acceptable selectivity, reproducibility, and stability. The prepared NPC-ZnO nanopolyhedra provide a new photoactive material for the construction of PEC sensors and may have promising applications in PEC assay of heavy metal ions, organic pollutants, and biomolecules.