N-Doped amber necklace-like structured MoS2@carbon nanofibers (ANL MoS2@CNFs) were fabricated via the confined growth method, constructing a hierarchical structure with 1D nanofibers, 2D nanosheets, and 3D cross-linked networks. This special structure could effectively alleviate the volume effect and enhance the storage performance of lithium/sodium ion batteries.