The invention relates to the field of PCB coding, and provides a direct coding method for a PCB. The direct coding method comprises the following steps: directly coding the PCB by using a carbon dioxide laser, wherein the size of the focus light spot of the carbon dioxide laser is equal to or smaller than 0.14 mm; aiming at two-dimensional codes or one-dimensional codes in different sizes requested on different PCBs, coding is realized by controlling the power of the carbon dioxide laser and selecting different coding modes. The high-precision, high-speed and programmable carbon dioxide laser is adopted to directly code the PCB, aiming at two-dimensional codes or one-dimensional codes in different requested sizes, the coding depth can be controlled by controlling the power of the carbon dioxide laser, and appropriate coding modes are selected, so that the PCB is not damaged in the coding process, automation can be achieved in the production process, and the labor and the materials can be saved; laser coding is not affected by assembling steps or environment, can be directly acted on the PCB, and the process lasting property is good, so that the effect that the code lasts for the whole life of the PCB is achieved.