The invention provides a preparation method and application of nitrogen and phosphorus co-doped porous carbon materials which are used in the aspects of electric catalysis, catalyst carriers, super capacitors, water treatment and the like. The method comprises that a carbon source, a nitrogen source, a phosphorus source and a carbonization activating agent are mixed in different proportions, ground, then subjected to high temperature carbonization treatment in nitrogen gas, and then subjected to acid treatment to obtain the porous carbon materials with different nitrogen and phosphorus compositions. The prepared carbon materials are used as non-noble metal catalysts; compared with traditional noble metal catalysts, the materials have the advantages of simpler preparation process, high activity, strong anti-poisoning ability, and good stability, and are ideal oxygen reduction catalysts for fuel cells. The prepared carbon materials are used as catalyst carriers; compared with traditional carbon powder carriers, the catalysts loaded with nanoparticles have the catalytic activity, stability, anti-poisoning ability and the like improved significantly. The carbon materials have relatively idea effects when used in the fields of super capacitors and water treatment.