This invention provides a method of surface treatment for magnesium or its alloy, which comprises the following steps: first, degreasing the surface of works, then immersing magnesium or its alloy into the treatment fluid and stirring the solution, the immersed temperature is indoor temperature, the immersed time is 0.5-10min. Said treatment fluid comprises 0.5%-10% oxalic acid, 0.5%-15% phosphorus acid, 1%-10% ammonium acid fluoride, 1%-3% inhibitor, 0.0005%-0.001% humectant by mass percent,and deionized water which is residual. Said inhibitor is one or more than of thiourea, hexamethylenetetramine and citric acid, and its proportioning is optional. Said humectant is sodium dodecyl sulfonate, OP-10 or carbowax. The invention has the merits such as high processing speed, simple process, less depletion and environmental protection.