Sodium-ion batteries (SIBs) are being increasingly studied due to their cost-effectiveness, high energy density and abundant resources. However, because of scanty interlayer spacing, commercial graphite-based materials that are currently used in lithium-ion batteries (LIBs) are not compatible for SIB anodes. Herein, we design a very convenient template strategy to synthesize spongy-like N, S-codoped ultrathin layered carbon assembly (NSLCA) with high N (9.5%) and S (1.7%) contents as an advanced anode material for SIBs. A petroleum-derived sulfur- containing pitch is chosen as the carbon skeleton, thus simplifying the preparation steps and reducing the costs. With the help of nanoporous MgO templates, the ultrathin layered carbon assembly can be facilely prepared. In addition, benefitting from the synergistic effects of codoped abundant N and S, as well as its unique assembly structures, the NSLCA anode exhibits outstanding sodium storage performance, with an especially superior rate performance (256 mA h g−1 at a current density of 3 A g−1) and a long lifespan (charge–discharge for as many as 2000 cycles with no capacity decay). This study provides a feasible and convenient strategy for the convenient and batch production of a spongy-like N, S-codoped carboneous material towards the construction of high-performance and cost-effectiveness SIBs.