Nature provides perfect varying models of hierarchical porous structures, but it remains a great challenge to accurately transfer these models intact to laboratory through carbonization during processing. In this study we report a new class of carbon materials whose hierarchical porous structure is accurately inherited from bagasse through a process consisting of a hydrothermal treatment with thiourea at 180 °C and then carbonization at 800 °C. The resulting composite structure consists of nanopores, supermicropores and ultramicropores with a high specific surface area of 2419 m2 g−1. The treatment with thiourea not only results in N and S doping but creates many papillae of a few hundreds of nanometer in diameter on the tubular wall. As a supercapacitor electrode working at 1 A g−1 in aqueous electrolyte, it shows a capacitance of 312 F g−1 (125 F cm−3), with 69% retention even at a very high current density of 20 A g−1. The material renders a good energy density of 11 Wh kg−1 at a power density of 125 W kg−1 and shows good cycling stability, 99.7% of initial capacitance remained after 10,000 charge/discharge cycles. As a lithium ion battery anode, it exhibited capacity of 621 mA h g-1 at 100 mA g-1 and the capacity remained at 310 mA h g-1 at 1000 mA g-1.