The effects of ultrasonic treatment on grain refinement and hydrogen removal in three kinds of magnesium alloys—Mg-3Ca, Mg-6Zn-1Ca, and AZ80 alloys—were investigated in this study. After ultrasonic treatment, the grains of the magnesium alloys were refined to varying degrees. The degassing effect was characterized by measuring the densities and hydrogen content of ingots. The results indicated that the application of ultrasonic treatment in these magnesium alloys was able to remove hydrogen and obviously refine the microstructure. In this experiment, both the measurement of the density of the ingots and the solid-state hydrogen measurement reflected the degree of degassing. The highest degassing efficiencies were 53.8%, 67.5%, and 34.9% for the Mg-3Ca, Mg-6Zn-1Ca, and AZ80 alloys, respectively. The lowest hydrogen content of the AZ80 alloy reached 8.2 cm3/100 g, and the corresponding tensile strengths were 174 Mpa, 79 Mpa, and 6.2%, which represented increases of 41.5%, 38.6%, and 87.9%, respectively. The cavitation effect and acoustic streaming effect with an appropriate ultrasonic treatment duration resulted in grain refinement, degassing, and the uniform dispersion of second phases. This can significantly improve mechanical properties and provide a basis for industrial production.