This research demonstrates a flexible one-pot strategy for fabricating three-dimensional (3D) boron/nitrogen-doped networks of carbon nanotubes(CNTs)/carbon nanosheets “Line-in-Wall” hybrids (LIW-NB) based on the space-confined template method. In the synthesis, the high rate of freezing step and freeze-dried process enable the CNTs and carbon-heteroatoms sources confined in the limited space of the self-assembled NaCl salts, which are then heat-treated to obtain a B/N-doped network constructed by “Line-in-Wall” type of carbon hybrids. By combining the 3D B/N-doped carbon nanosheets network and CNTs in this unique pattern, the LIW-NB integrates advantages of three aspects: first, the doped heteroatoms enhancing electrochemical properties of carbon matrix; second, the warp-proof nanosheets supplying high specific surface area; and the extracted and embedded CNTs serving as electron conductive paths and reinforcing the whole architecture. As a result, the 3D LIW-NB shows excellent electrochemical properties: as the electrode of supercapacitors, LIW-NB exhibits high specific capacity at different current densities (389Fg−1 at 1Ag−1 and 129Fg−1 at 20Ag−1); as the lithium ion battery anode, it possesses high reversible storage capacity (1165mAhg−1 at 0.1Ag−1) and stable long cycle performance at high rate (1000 cycles at 2Ag−1).