The invention relates to the field of thermal insulation materials and provides a preparation method of polyimide aerogel. The method is characterized by comprising the following steps: step 1, preparing polyamide acid hydrogel; step 2, freezing the polyamide acid hydrogel at low temperature, and performing freeze drying and thermal imidization to obtain the polyimide aerogel. The prepared polyimide aerogel has low density, high strength and high flame retardant capacity, isotropic and anisotropic thermal insulation materials can be obtained, various application scenarios can be met, the preparation process is simple and easy to operate, shorter time is needed, cost is low, environmental protection is realized, toxic solvents are not used, and the potential of large-scale application is provided.