The counter electrodes (CEs) as the basic components of dye-sensitized solar cells (DSSCs) mainly use Pt-based catalysts. It is still an urgent need to decrease the assembled cost of DSSCs by designing high-performance and low-cost Pt-free materials to replace the scarce and expensive Pt as CEs catalyst. How particularly striking are that specific precursors were prepared by ball-grinding with polyoxotungstate (H3PW12O40) as metal source and melamine (C3N3(NH2)3) as carbon source and nitrogen source, and then the pyrolysis process of precursors were dynamically controlled along the temperature gradient to make the auxiliary groups leave, so as to obtain the expected N-doped W2C catalytic materials. Herein, four kinds of N-doped W2C materials have derived from polyoxotungstate precursors at the pyrolysis temperatures of 700, 800, 900 and 1000 °C, and further applied to assemble CEs catalysts in DSSCs. The high power conversion efficiencies (PCE) of 6.10, 7.01, 5.95 and 5.34% were obtained for the regeneration of traditional iodide/triiodide (I3−/I−), respectively. The enhanced performance of N-doped W2C materials can be attributed to the larger number of catalytic active sites, which was due to the higher specific surface area provided by pyrolysis and carbonization of organic complex precursor, and the activation and modification of materials by the N-doped and the high temperature.