The invention discloses a method for machining a solder mask of a circuit board through a laser. The method comprises the step of performing preprocessing, coating printing and exposure and removing an unnecessary soldering preventing green paint protection layer through the laser. The development technology is replaced by the technology of removing the protection layer through the laser, waste water is not produced, environmental friendliness is achieved, energy is saved, and production cost of enterprises can be reduced. In the exposure step, the soldering preventing green paint protection layer can be directly exposed through a high-energy UV light source, the exposure speed is high, the whole face of the circuit board is directly irradiated in the exposure process, a light painting film shade does not need to be adopted, the pre-drying and post-drying steps can be omitted, the production technology is simplified, and the production cycle of products can be shortened. In the step of removing the unnecessary soldering preventing green paint protection layer through the laser, laser dynamic scanning is adopted, an image scanned by the laser can be dynamically adjusted according to deformation of the circuit board, and the quality of the products is improved.