N-doped hierarchical porous carbon was prepared by the carbonization of a polypyrrole precursor and activated using potassium hydroxide. The resulting carbon material has a specific area as high as 3271m2 g−1 and a hierarchical porous structure consisting of mixed parts microporous (<2nm) and low-range mesoporous (2–50nm) volumes with majority of pores less than 3nm in diameter. Sulfur/carbon composites with 80wt% and 90wt% sulfur contents were obtained using a simple wet chemical deposition method. It is found that the sulfur is uniformly dispersed inside the nanopores, which is favorable for both the good utilization of sulfur and the confinement of intermediated soluble lithium polysulfides. N-doping can further enhance the chemical interaction between polar polysulfides and the carbon host. When used as a cathode, this composite with high sulfur content exhibited good cycle and rate performance.