The present invention relates to the application of ionic liquids individually or in formulation to dry and desalt crudes oils having API gravities in the range of 8 to 20 (median, heavy and extra-heavy) when applied at concentrations ranging from 500 and up to 5000 ppm. The ionic liquids have a cation consisting of quaternary ammonium, wherein the substituents R, R1 and R2 are independent radicals represented by alkyl chains including 2 to 8 carbon atoms; and anion selected from the group consisting of ethylsulfate, methylsulfate and chloride.