The invention relates to a chitosan crude oil demulsifier and a preparation method thereof. A structure general formula of the demulsifier is as shown in formula I, and the preparation method thereofcomprises the following steps: 1) performing acylation modification on chitosan, to obtain N-acylated chitosan; 2) performing epoxidation modification on a terminal hydroxyl of methoxypolyethylene glycol, to obtain epoxidation methoxypolyethylene glycol; 3) enabling the modified methoxypolyethylene glycol to react with N-acylated chitosan, to obtain methoxypolyethylene glycol grafted N-acylated chitosan; and 4) performing carboxy alkylation modification on the methoxypolyethylene glycol grafted N-acylated chitosan, to obtain a target product of methoxypolyethylene glycol grafted N-acylated carboxy alkyl chitosan. The demulsifier is capable of using chitosan natural macromolecular compounds as raw materials, and has the advantages of wide source, nature, non-toxicity, good biocompatibility,degradation and the like. A carboxy alkyl, an acyl and a polyether side chain are introduced into a chitosan molecular chain, and through controlling a position and a substitution degree of each substituent group, a series of the efficient demulsifiers suitable for oil-in-water (O / W) emulsion is obtained.