Carbon materials with porous structure and high conductivity are popular scaffold in lithium-sulfur batteries. However, the difficulty in fabrication restricts their application. In this work, a facile method to fabricate nitrogen and phosphorus co-doped multi-scaled porous carbon is reported. The porous carbon (named as CPANiP-NaCl) with highly interconnected network structure was fabricated by pyrolysis of phytic acid cross-linked polyaniline aerogels with the assistance of sodium chloride (NaCl). NaCl served as a hard template before melting, which helps to keep the interconnected framework of precursor and prevent the generated carbon intermediates stacking into bulks. Molten NaCl provides an inner media to facilitate dissolved oxysalt (PO43−) to partially oxidize the carbon intermediates and generate micro-pores. Improved specific surface area and porous volume promote the impregnation of sulfur and electrolyte, and the high conductivity of CPANiP-NaCl enhances the electron transportation. Besides that, physical absorption of micro-pores and chemical anchoring of doped heteroatoms accelerate the transformation of polysulfide species. The simultaneously enhanced confinement to polysulfide species with different polarities helps realize the superior cyclic stability and rate performance of CPANiP-NaCl/Sulfur. Finally, the cells maintain the capability of 652 mAh⋅g−1 (1 C = 1675 mAh⋅g−1) at 0.5 C and 94% capacity retention after 120 cycles.