Nitrogen-doped carbon nanofiber (NDCN) was synthesized via carbonization of polypyrrole (PPy) coated bacterial cellulose (BC) composites, where BC serves as templates as well as precursor, and PPy serves as the nitrogen source. The synthesized NDCN was employed as electrode for both supercapacitors and Li-ion batteries. The large surface area exposed to electrolyte resulting from the 3D carbon networks leads to sufficient electrode/electrolyte interface and creates shorter transport paths of electrolyte ions and Li+ ion. Besides, the three types of N dopants in NDCN improve the electronic conductivity, as well as superior electrochemical performance.