• The 3D Co 9 S 8 @NPC composite is synthesized by simple template method and annealing. • The unique structure enhances the stability of the system for ions transmission. • The Co 9 S 8 @NPC electrode exhibits outstanding potassium storage performances. • Kinetic behaviors and insertion mechanism of K + are investigated via DFT. In this work, we synthesized a three-dimensional porous nitrogen-doped carbon composite with a uniform dispersion of MOF-derived Co 9 S 8 nanoparticles (3D Co 9 S 8 @NPC) via a simple template method combining with in situ high temperature pyrolysis. As K-ion battery anode, the 3D Co 9 S 8 @NPC exhibits a high specific capacity of 315 mA h g −1 at 0.1 A g −1 after 200 cycles, as well as a capacity of 223 mA h g −1 at 1 A g −1 after 1000 cycles, which is superior to the performance of KIB metal sulfide-based anode materials reported previously. The excellent performance is attributed to more pore structure and active sites in 3D Co 9 S 8 @NPC, which reduce efficiently K + diffusion length and accelerate the insertion/extraction of K + . The 3D N-doped carbon matrix also speeds up electron transport and buffers the volume expansion of Co 9 S 8 . Moreover, density functional theory (DFT) calculations demonstrate that due to the small energy change of K ion on Co 9 S 8 surface, the 3D Co 9 S 8 @NPC electrode is expected to show ideal rate capability in the K-ion battery system. This work provides ideas to craft other 3D structure anodes towards high-performance metal-ion batteries.