Lithium-sulfur (Li-S) batteries have attracted particular interests owning to their high theoretical specific capacity and energy density. However, some key issues hinder the development of Li-S batteries. One is that sulfur is a low conductivity element, which leads to poor electrochemical contact and low utilization in Li-S batteries. Another one is shuttle effect brought by the dissolution of the polysulfides. Much effort have been paid to the development of low-cost and conductive material as matrix to disperse active sulfur for Li-S batteries. Hereby, we present a strategy to synthesize three-dimensional (3D) nitrogen-doped hierarchically porous carbon material (NHPC) from biowaste (e.g., shrimp shell) via sustainable hydrothermal carbonization and CO2 activation process. The obtained material possesses 3D micro-meso-macroporous structure with relatively large Brunauer-Emmet-Teller specific surface area (up to 1190 m2/g). The properties of the material, such as morphology, porous structure, elemental composition, degree of structural order, and functional group, were investigated. It is found that both the hydrothermal carbonization and CO2 activation procedures play virtual roles in the formation of hierarchically porous structure. During the HTC procedure, the chitin in shrimp shell was transformed into N -doped carbon. The carbon structure stabilized, which avoids the structure destroying during the acid washing and further activation procedures. The control material synthesized without hydrothermal carbonization is microporous material. The CO2 activation procedure introduce micro- mesopores into the carbon structure, the control material synthesized without CO2 activation (only hydrothermal carbonization and thermal treatment) possesses much lower specific surface area compared with NHPC. The obtained N -doped 3D hierarchically porous carbon was used as matrix to load sulfur (S@NHPC). The energy dispersive spectroscopy (EDS) mapping experiment was conducted to investigate the element distribution of the carbon, nitrogen, and sulfur. The results show that the carbon, nitrogen, and sulfur species are uniformly dispersed. This phenomenon indicates that the nitrogen and sulfur are well distributed in the carbon material, which results in good electrical contact of sulfur and the N -doped carbon matrix. The types of the carbon, nitrogen, and sulfur functionalities of the materials were further studied by X-ray photoelectron spectroscopy (XPS) technique. After the activation/carbonization process, the quaternary N was detected, which confirms that the structural order increases during the CO2 activation procedure. This phenomenon was further proven by X-ray diffraction (XRD) and Raman results. It was reported that the nitrogen functionalities not only enhance the electrical conductivity of the carbon materials, but also prevent the polysulfides shuttling in Li-S batteries. The electrochemical performance of the S@NHPC as cathode in Li-S batteries was studied. The micro-meso- macroporous structure is helpful for electrolyte immersion and diffusion. In addition, the nitrogen functionalities increase the conductivity of the carbon materials and confine the diffusion of the Li2S n diffusion. The synergistic effect of the nitrogen, sulfur and 3D hierarchically porous structure makes the material possess good performance as cathode in Li-S batteries. Considering the material is biowaste-based, and the synthesis process is facile and sustainable, the 3D NHPC materials have the potential to be good electrode materials in electrochemistry. Furthermore, it is believed that the method used in this work supplies a sustainable and facile way for transforming polysaccharides and inorganic components containing natural biomass or biowaste into functionalized hierarchically porous carbon materials.