The invention discloses a viscoelastic surfactant for high-temperature self-diverting acid. The structural formula of the viscoelastic surfactant is as shown in the specification, wherein n refers tosaturated alkane with 2-8 carbon atoms, R1 refers to saturated or unsaturated alkane with 18-28 carbon atoms, R2 and R3 refer to independent methyl, ethyl and hydrogen atoms and can be the same or different, and X refers to optional one of Cl<->, Br<->, F<->, CO3<2->, SO4<2->, HCOO<-> and CH3COO<->. The preparation method includes subjecting aliphatic acid and organic amine to acid and amine condensation reaction to obtain an intermediate product, subjecting the intermediate product to reaction with metallic oxide to obtain aliphatic amine, adding in acid solution to perform protonation, so asto obtain the very-long viscoelastic cation surfactant. The invention further provides the application of using the surfactant as a thickening diverter of self-diverting acid. The self-diverting acidutilizing the surfactant as the thickening diverter can be used at the temperature of 150 DEG C, and has the advantages of stable structure, thickened acid, uniform acidification, automatic divertingand the like.