Biomass-derived carbons are attractive and cost-effective anode materials for sodium ion batteries (SIBs), however, they generally suffer from the low capacity and coulombic efficiency. Foreign atom doping has been proved to be an effective approach to tune the chemistry of carbon material and improve their electrochemical performance. In this contribution, nitrogen (N)-doped carbon spheres (NCs) were successfully prepared from onion waste and urea (CH4N2O) by hydrothermal and annealing process, with urea as cheap and additional nitrogen source. The thus-derived NC was used as anode material for SIBs, the optimal sample (NC-800) can harvest a reversible capacity of 152 mAh g−1 at a current density of 0.05 A g−1 after 200 cycles. Impressively, NC-800 can still offer 83 mAh g−1 capacity after 2000 cycles at 1 A g−1, with a capacity retention rate of 69%. The high performance of N-doped carbon (NC-800) can be attributed to the significant increase of defects and the enlargement of interlayer distance caused by nitrogen doping. This work presents a feasible fashion of converting low-value waste into high-value material for energy storage.