ABSTRACT The peanut shells derived porous hard carbons (PSDHCs) by pyrolysis have been investigated as anodes of lithium/sodium batteries (LIBs/NIBs). Directly from the starting peanut shells, 600°C is found to be the favorable pyrolysis temperature for preparation of the PSDHC sample (PSDHC-600) with the best electrochemical performances for LIB applications. Furthermore, from the activated peanut shells in KOH solution, the produced PSDHC-600A by pyrolysis at 600°C is observed to offer greatly enhanced Li+/Na+ ion storages. For LIB applications, PSDHC-600A delivers a retained capacity of 474mAhg−1 after 400 cycles at 1Ag−1, larger than 314mAhg−1 of PSDHC-600. At a high current rate of 5Ag−1, PSDHC-600A sustains over 10000 cycles with no obvious sign of fade in capacity, and a capacity of 310mAhg−1 is still retained. For NIB applications, a capacity of 193mAh g−1 is retained after 400 cycles at 0.25Ag−1, higher than 130mAhg−1 of PSDHC-600. Even at 1Ag−1, PSDHC-600A can be stably cycled over 3000 cycles, and a capacity of 129mAhg−1 is still retained. In comparison to PSDHC-600, the enhanced electrochemical properties of PSDHC-600A can be attributed to the finer porous structure with the increased percentage of nanoscale pores of diameter less than 2nm and the larger specific surface area.