Designing a green flexible alginate hydrogel as a biomedical material is essential. Here, on the theoretical basis of the weak cross-linking ability of magnesium ions (Mg 2+ ) and the mechanical supporting role provided by calcium ions (Ca 2+ ), we successfully prepared uniform and dense magnesium−calcium sodium alginate (Mg m Ca n -SA) flexible hydrogel using soft spray. Results of mechanical test showed that Mg 2+ and Ca 2+ exhibit mechanical synergy, and the elongation and toughness of Mg 3 Ca 7 -12-SA were 140.11% and 0.809 MJ/m 3 , which were increased by 37% and 47% compared with Mg 0 Ca 10 -12-SA, respectively. The swelling and drug release behaviors of Mg m Ca n -SA hydrogel depicted good sensitivity at different physiological pH. Within 1 h of the initiation phase, the lowest release fractions in simulated gastric fluid (SGF) and simulated intestinal fluid (SIF) were 11% and 28%, respectively. In addition, the dense structure formed at high Mg 2+ content (Mg 9 Ca 1 ) gave the hydrogel a highly flexible property, a higher encapsulation efficiency (EE), and a slower drug release. The release of ibuprofen from Mg m Ca n -SA was controlled by Fickian diffusion based on the Korsmeyer-Peppas model and the one-order kinetic model. Therefore, the prepared alginate flexible hydrogels have potential for applications in green and soft material regions for the future development of conventional and digital biomedicine.