Efficient electrodes with impressive storage capability and fast kinetic processes are urgently needed in meeting the demand for high energy and large rate powering devices. Through a simple silica templated ionic liquids (ILs) impregnating method and an annealing process, nitrogen and oxygen co-doped carbon nanobubbles are synthesized. The fabricated carbon nanobubbles feature multiscale nanopores and abundant few-layer graphitic zones in the thin shells of several nanometers. When used as anodes for lithium-ion batteries (LIBs) and sodium-ion batteries (SIBs), the nanobubbles not only exhibit excellent storage capability and rate performance, but also achieve enhancing cyclibility in the long-term cycles. Further analysis on the charging curves and the electrochemical impedance spectroscopy (EIS) reveal the enhancing cyclibility and storage capability might depend on the interfacial capacitance derived from quasi-connection between Li+ or Na+ and the hetero-atom evolving dissociative groups, while the superior rate performance might be attributed to the low interfacial charge-transfer resistance in the carbon nanobubbles electrode.