Magnesium (Mg) and its alloys as biodegradable metallic materials have attracted fundamental research in the field of orthopedics and cardiovascular materials. However, magnesium implants exhibit poor corrosion resistance, especially in the physiological environment, which limits medical applications. To improve the corrosion resistance of the Mg, anodization was applied to an ultra-high concentration of fluoride electrolyte. Then, surface morphology, coating thickness and composition were determined, and the corrosion behavior of anodized Mg alloys was evaluated. The results of coating by anodization showed that a porosity structure with a pore size of 600–900 nm and thickness of 1–14 μm is generated on the Mg alloy substrate, and this coating component is magnesium fluoride. In electrochemical corrosion tests and immersion corrosion tests, the anodized Mg alloy was tested, and the anodized Mg alloy shows significantly improved corrosion resistance compared with untreated Mg alloy in simulated body fluid (SBF).