Acesulfame potassium (AK) is an artificial sweetener that contains N and S functional groups in its organic moiety and is suitable as porous carbon precursor. In this study, AK derived carbon (AKC) was obtained via direct carbonization and in situ doping without additives under the dual conditions of inert gas protection and high temperatures. The obtained AKCs exhibited high porosity structure with a specific surface area of 2043 m2 g−1 and 3.22 wt% N and 8.61 wt% S dual heteroatom doping. When applied to the supercapacitor electrode, the AKC ensured a high capacitance of 264 F g−1 at 0.5 A g−1, which maintained 86.1 % of the initial capacitance after 5000 cycles at 5 A g−1, and an ultra-high energy density of 16.3 Wh kg−1 in a full cell device. By analyzing its application in the lithium‑sulfur battery cathode, the S-loaded AKC exhibited a high capacity of 1075 mAh g−1 at 0.1C, and 490.5 mAh g−1 after 150 cycles with 66.5 % of capacity retention. The excellent performance of AKC can be attributed to its high specific surface area, pore structure, and sulfur and nitrogen co-doping combine effect. Overall, AKCs exhibited excellent electrochemical performances, thereby proposing a new synthetic strategy of preparing dual heteroatom doped porous carbon for high-performance electrode materials through a single precursor and low-cost perspective.