Nitrogen-doped carbon nanoribbons and nanotubes decorated with Co3O4 nanoparticles were prepared by a metal-catalyzed graphitization-nitridization and oxidization process, using triazole and melamine as a solid nitrogen/carbon co-source, and assessed as anodes of lithium ion batteries (LIBs). These composite anodes display perfect electrochemical performance, indicating their potential for application in LIBs.