A novel sulfur–nitrogen co-doped carbon material (SNC), which is obtained by taking polyaniline as the nitrogen-containing carbon precursor and then incorporating sulfur atomsin situas the matrix material for lithium sulfur batteries, is investigated.