The invention discloses a preparation method and the application of polyimide varnish. The method comprises the steps of dissolving the refined aromatic diamine and aliphatic diamine into the refined organic solvent, then adding the refined aromatic dianhydride in batches, and stirring and reacting for several hours under the protection of low-temperature inert gas to obtain polyimide varnish; after the varnish is filtered for multiple times, covering the surfaces of microelectronic devices with the varnish such as rectifiers, diodes, triodes, high-power silicon controlled rectifiers, high-voltage silicon stacks, thyristors and the like and large-scale integrated circuit patterns by adopting methods such as drop coating, roller coating, silk-screen printing and the like, and high-insulation, high-strength and then obtaining low-expansion electronic components through stepped heating and curing. The method has the advantages of accessible raw materials and simple operation, and is suitable for large-scale industrial production.