Metal sulfides are widely used in lithium-ion batteries (LIB) and sodium-ion batteries (SIB) due to their large specific capacity and superior electrochemical performance. In addition, metal gallium (Ga) is regarded as a promising self-healing anode material for LIBs and SIBs. In this paper, we combine the two side to efficiently synthesize the carbon-coated Ga2S3 by vacuum sealing heat treatment based on the novel metal-organic frameworks (Ga-MOF). The carbon skeleton inherited from the Ga-MOF precursor can limit the volume expansion of Ga2S3 during cycling. In addition, the modification of Ga-MOF, employing organic ligands (BTC) to replace solvent sites in MOF clusters, is not only carried out to enhance the mechanical properties of the carbon framework, but also to further improve the conductivity of the Ga2S3/C material. In particular, the post-synthetic modification MOF-derived Ga2S3/C (Ga2S3/C-PSM) material exhibits the excellent cyclability with a reversible capacity of 918 mAh g−1 for LIB and a reversible capacity of 385 mAh g−1 for SIB after 200 cycles at a current density of 100 mA g−1, respectively. We believe that this work indicates a novel and efficient way to improve the electrochemical stability for Li-ion and Na-ion batteries.