A design method of laser beam shaping freeform surface lens is proposed, which can be applied to shape the diverging laser beam. Freeform surface lens design is a two-step process. Firstly, an initial lens layout is designed by establishing the input-output energy mapping relationship. Then, the reverse feedback optimization method is used to optimize the initial freeform lens when the divergent beam is applied. By this method, a freeform lens is designed for shaping a laser beam with beam waist of 10 mm and a half divergence angle of 2.5°. The simulation results show that the freeform lens can transform a Gaussian beam into a 40 mm×40 mm top-hat beam with an irradiance uniformity of 90.4%. Finally, the machining error analysis and the assembly tolerance analysis of the freeform lens are performed. It is shown that the uniformity is almost unchanged while the process error varies from -5 μm to 5 μm. And the longitudinal deviation error dz has little influence on the irradiance uniformity, but the lateral deviation error dx and slant angle error dφ have a significant influence on the irradiance uniformity.