Tin(ii) sulfide (SnS) is considered to be one of the most promising anode materials for lithium/sodium ion batteries (LIBs/SIBs) due to its high theoretical capacity and low-cost. However, its practical applications are severely impeded by its low electrical conductivity and large volume change upon cycling. Herein, we demonstrate a high-performance SnS/TiO2 encapsulated by a carbon shell (SnS/TiO2@C) synthesized by facile coprecipitation and annealing treatment. The exterior carbon coating can not only improve the conductivity, but also effectively relieve volume variation to maintain the structural integrity during cycling. Significantly, the internal SnS/TiO2 heterostructure formed a built-in electric field to provide favorable driving force for ion transfer. Consequently, the synthesized SnS/TiO2@C delivered a reversible capacity of 672.4 mA h g-1 at 0.5 A g-1 after 100 cycles for lithium storage and 331.2 mA h g-1 at 0.2 A g-1 after 200 cycles for sodium storage. Meanwhile, ultra-long lifespans of 3000 cycles at 5.0 A g-1 with a capacity of 394.5 mA h g-1 for LIBs and 750 cycles at 5.0 A g-1 with a capacity of 295 mA h g-1 for SIBs were achieved. The electrochemical reaction mechanisms of the SnS/TiO2@C electrode have been investigated by in situ XRD, ex situ XRD, and ex situ HRTEM. Our work may offer further understanding of the hierarchical structure to boost the electrochemical properties of the electrode materials.