CoSe2-SnSe2/NC nanocubes (CSNC@NC) coated by nitrogen-doped carbon (NC) were synthesized successfully by an ordinary pyrazole polymerization and carbonization process. In comparison with bare CSNC, the CSNC@NC composite exhibited good structural stability and improved electrical conductivity when used as anode. The CSNC@NC electrode showed a stable Li storage capacity (730.41 mAh g−1 over 100 cycles at 0.2 A g−1) and excellent rate performance (402.10 mAh g−1 at 2 A g−1). For Na storage, the discharge capacity could be maintained 279.3 mAh g−1 over 100 cycles at 0.2 A g−1; the lower capacity than that for Li storage maybe caused by the larger size of Na+ ions. The excellent cycling stability for both Li and Na storage cycle ability may be attributed to the carbon layer, which could tolerated the volume fluctuations and ensured the structural integrity of the CSNC during the charge/discharge process; Moreover, the improved electrical conductivity accelerated the diffusion rate of both Li+ and Na+, which is conducive to the electrochemical reactions in their respective batteries. This unique structure and preeminent electrochemical performance of CSNC@NC show that CSNC@NC is a promising anode material for high-efficiency Li ion and Na ion batteries.