Nitrogen-doped porous carbon synthesised from garlic peel by a simple and cost-effective method has been employed as an anode material for the sodium ion (SIB) as well as lithium ion batteries (LIB). The synthesised material has been found to be mesoporous with a high specific surface area (SSA) ∼1710m2 g−1, as calculated with Brunauer–Emmett–Teller (BET) isotherm. Further, Field Emission Scanning Electron Microscopy (FE-SEM) and Transmission Electron Microscopy (TEM) analysis reveal the existence of interconnected micro-pores and voids. The N-doped garlic peel carbon (GPC) exhibits excellent rate capability as well as steady state cycling performance towards sodium and lithium ion shuttlings. Discharge capacities of about 142, 89, 58, 37mAhg−1 have been achieved at various current densities such as 0.5, 1.0, 2.0, 4.0Ag−1 respectively in a CR-2032 type Na-ion cell. Similarly, the Li-ion cell delivered reversible capacities of about 320, 280, 215 and 145mAhg−1 at different current densities of 1.0, 2.0, 4.0 and 8.0Ag−1 respectively. The high electrochemical performance of the N-doped GPC is mainly attributed to the existence of nitrogen in the carbon matrix and mesoporous structure coupled with a high surface area for accommodating large number of Li/Na ions.