N/P co-doped carbon nanosheets (NPC) have been prepared by a simply direct pyrolysis method using amino tris(methylene phosphonic acid) (ATMP) as carbon, nitrogen and phosphorus co-sources, and utilized as Pt-free counter electrodes (CEs) for dye-sensitized solar cells (DSSCs). The prepared N/P co-doped carbons with amorphous structure and platelet-like morphology exhibit rapid electrolyte diffusion. More importantly, the content of N/P dopants and doping states are temperature-dependent, and particularly the N/P dopants are easy to be eliminated at high temperature, accompanied with the introduction of defective sites into the carbon matrix, thus regulating the catalytically active sites and electrical conductivity of N/P co-doped carbon nanosheets. The electrochemical impedance spectroscopy, Tafel, and cyclic voltammetry measurements demonstrate that the NPC carbonized at 800°C (NPC-800) with appreciable N/P doping content and suitable defective sites displays the best catalytic activity. As a consequence, the DSSC based on NPC-800 CE achieves a power conversion efficiency of 6.74%, which is higher than that of the cell with Pt CE (5.76%).