S/C composites in lithium-sulfur (Li-S) batteries are conventionally prepared by melt-diffusion method, by which S is difficult to uniformly distribute into matrix. Herein, a novel 3D N-doped carbon/sulfur (S/CNx) composite is fabricated by a simple in situ oxidizing reaction, which delivers a specific capacity of 830 mA h g−1 at 1 C after 100 cycles with 98.8% of capacity retention. The unique synthetic strategy in this work could provide a new thought for designing high performance Li-S batteries.