Nitrogen, oxygen and sulfur tridoped porous carbons have been successfully synthesized from natural biomass algae-Carrageen by using a simultaneous carbonization and activation procedure. The doped carbons with sponge-like interconnected architecture, partially ordered graphitic structure, and abundant heteroatom doping perform outstanding features for electrochemical energy storage. When tested as lithium-ion battery anodes, a high reversible capacity of 839mAhg−1 can be obtained at the current density of 0.1Ag−1 after 100 cycles, while a high capacity of 228mAhg−1 can be maintained at 10Ag−1. Tested against sodium, a high specific capacity of 227 can be delivered at 0.1Ag−1 after 100 cycles, while a high capacity of 109mAhg−1 can be achieved at 10Ag−1. These results turn out that the doped carbons would be potential anode materials for lithium- and sodium-ion batteries, which can be achieved by a one-step and large-scale synthesis route. Our observation indicates that heteroatom doping (especially sulfur) can significantly promote ion storage and reduce irreversible ion trapping to some extent. This work gives a general route for designing carbon nanostructures with heteroatom doping for efficient energy storage.