Lithium sulfur (Li-S) batteries possess high theoretical specific capacity (1675mAhg−1) and energy density (2567Whkg−1), but are plagued by their poor rate performance. The discovery of new carbon sources, design of novel porous carbon structures, and effective hetero-atom doping of the sulfur matrix are key to overcome this dilemma. In this paper, a boron-doped porous carbon material with a termite nest shape (TNPBC) was obtained from a new carbon source, polyaspartic acid, and borax. Importantly, the doping, activation, and pyrolysis were integrated into one step through a low cost and simple methodology. The borax was essential to formation of a high surface porous architecture and provided boron dopants, which, combined with polyaspartic acid, achieves co-doping (B and N) carbon materials with special porous structures. The simultaneous pore-formation and doping leave an abundance of hetero-atoms exposed on the surface of pores, which enhances the electrostatic interactions between the hetero-atoms and the charged species in the batteries. As a result, the S/TNPBC cathode maintains a stable capacity of 703mAhg−1 with an excellent Coulombic efficiency of 101.3% after 120 cycles at 0.1C. Moreover, it exhibits an excellent rate capability with an initial capacity of 650mAhg−1 at 0.5C and sustains a capacity of 500mAhg−1 after 100 cycles. Furthermore, when TNPBC is used as the anode in a sodium ion battery, an excellent rate capability is achieved. The specific charge capacity is three times greater than without boron doping at 500mAg−1. Due to the simple fabrication process and desirable properties of this novel architecture, TNPBC provides a new strategy for enhancing the performance of commercial energy storage devices.