A device that uses a deformable mirror to realize automatic beam shaping, consisting of a laser, a telescope, a deformable mirror, a CCD camera, a D / A conversion card, a high-voltage amplifier, a variable density attenuation disk, a main control computer, an image acquisition card, a focusing lens, and a genetic control Algorithm composition, the present invention uses the genetic algorithm to control the deformable mirror, by changing the phase distribution of the near-field wave surface of the laser beam, so as to achieve the purpose of changing the shape of the far-field spot, without calculating the relationship between the far-field spot shape and the near-field phase Under the premise of the formula, laser beam shaping can be realized; not only can the Gaussian laser beam be shaped into super-Gaussian beam, square beam, etc. Correction. The invention has the advantages of simple structure, strong versatility and easy realization, can be applied to occasions with specific requirements on the shape of the laser beam, and can greatly expand the application field of the laser.