Doped materials with well-defined morphologies have attracted substantial research interest due to their excellent activity and stability in fuel cells. Herein, celery-like nitrogen and phosphorous co-doped carbon nanofibers frameworks (PNCNF) have been successfully fabricated via a novel in-situ doping and self-assembly strategy, serving as superior supports for uniform Pt nanoparticles. The resulting Pt/PNCNF composite possesses a porous architecture and high-surface area, which exhibits remarkable mass activity, durability, and anti-poisoning ability towards oxygen reduction and methanol oxidation reactions, compared to the commercial Pt/C electrocatalyst. In addition, the high CO tolerance of Pt/PNCNF could be ascribed to a strong interaction between the Pt nanocrystals and PNCNF, which facilitates OH− adsorption to remove CO intermediate. The improved electrocatalytic properties benefit from the morphological and compositional advantages of the N and P co-doped carbon nanofiber frameworks. Specifically, the orientation of celery-like carbon nanofibers layers in Pt/PNCNF optimizes its mechanical properties. This synthetic strategy for the preparation of N and P co-doped carbon is envisaged as a new and general pathway for the rational engineering of heteroatom doped carbon composites for renewable energy conversion applications.