||Recent research has shown that non-graphitizable hard carbons exhibit high capacity for alkali (e.g., Li, Na and K) ion battery. However, the use of conventional hard carbon is limited by its low electronic conductivity, inferior cycling stability, and poor rate performance. Doping heteroatoms (e.g., N, B, S, and P), one of the ways to overcome these problems, has been proved to significantly enhance the electrical conductivity and provide the channel for electron transfer to facilitate the charge transfer and electrode–electrolyte interactions. Prepared melamine-formaldehyde aerogels were synthesized by polymerization of melamine as polymer precursor and formaldehyde using sol–gel method. In this study, with various heat treatment, we prepared samples with a variety of microstructure and different heteroatom contents. Then we investigated discharge profile, rate stabilities and Columbic efficiencies for demonstrating rate and cycling performance for alkali ion battery.