Rational design of efficient and durable anode materials is particularly momentous for high-performance lithium-ion batteries (LIBs) and sodium-ion batteries (SIBs). According to this concept, an effective strategy to prepare MoS2/N, S co-doped graphene by electrochemical exfoliation combining hydrothermal route is presented. Due to N and S atoms co-doping to graphene sheets, the three-dimensional interconnection of few-layered MoS2 and graphene, which contribute to relieving the restacking of the two components, accelerating the electrons transport and improving Li/Na storage capacity. As an anode in LIBs, the MoS2/NSG-AG demonstrates an up to reversible capacity of 1012 mAh g−1 after cycling 300 times at 0.5 A g−1 and good rate performance with a capability of 1300.7, 1215.2, 1106.3, 1005.5, 892.7 and 727.7 mAh g−1 at 0.1, 0.2, 0.5, 1.0, 2.0 and 4.5 A g−1, respectively. Furthermore, it delivers a maximum energy density of 890 Wh kg−1 along with the power density of 130 W kg−1. Meanwhile, when used in SIBs, it displays a good reversible capacity of 320.9 mAh g−1 after cycling 500 times at 0.5 A g−1. The prominent electrochemical performance could be due to the three-dimensional network formed by interconnection of MoS2 and graphene, co-doping of N and S, considerable surface area and rich mesoporous as well as the expanded layer spacing of graphene and MoS2. Therefore, this is a facile strategy to obtain high-performance hetero-structured anode and make it great potential applications in LIBs and SIBs.