A novel method of producing ursodeoxycholic acid was developed through electrochemical stereoselective reduction of 7-ketolithocholic acid (7K-LCA) in a undivided electrolytic cell and aprotic solvents as electrolyte. Five aprotic solvents were investigated as electrolytes, the simple structure of dimethyl sulfoxide (DMSO) and N,N-dimethylformamide (DMF) were easily attacked by chloride ions and undergo nucleophilic reactions, resulting in no target reactions. The structure of hexamethylphosphoric triamide (HMPA) and 1,3-methyl-3,4,5,6-tetrahydro-2 (1H) -pyrimidinone (DMPU) is relatively complex, but chloride ions can still attack them, and it was easier for 7K-LCA to directly undergo a reduction reaction under the action of electric current, because of the small steric hindrance of chenodeoxycholic acid (CDCA), 7K-LCA was stereoselectively reduced to CDCA. Due to the stable structure of the five-membered imidazole ring of 1,3-dimethyl-2-imidazolidinone (DMI), 7K-LCA undergoes two nucleophilic and a "Walden inversion", thereby stereoselective reduction of 7K-LCA to UDCA. In DMI, the highest conversion rate of 7K-LCA was 58.3%, the yield of UDCA was 34.9%, ee value was 100%. Linear sweep voltammetry was used to explore the electrochemical behavior of the reaction, and the electrolysis results were consistent with the linear sweep voltammetry. The product was characterized by using IR, 1H NMR and 13C NMR, it confirm the product was UDCA. The method developed in this paper provides a relatively environmentally friendly and low-consumption method for large-scale production of ursodeoxycholic acid, and provides a valuable reference for the asymmetric electrochemical reduction of ketone groups.