Background Type 2 diabetes has become one of the most common diseases worldwide, causing a serious social burden. As a first-line treatment for diabetes, metformin can effectively improve insulin resistance. It has been reported that 12α-hydroxylated BA (mainly CA) is associated with insulin resistance. The purpose of this study was to analyze the changes in CA and possible signaling mechanisms in diabetic rats after metformin intervention. Methods HepG2 cells were cultured after adding different concentrations of metformin. The cell viability was measured using CCK8 kit, and the expression of FXR, MAFG, and CYP8B1 in cells was detected by WB. The rat models of type 2 diabetes were induced by low-dose streptozotocin by feeding a high-fat diet, and the control rats (CON) were fed on normal food; the diabetic rats (DM) were given a high-fat diet without supplementation with metformin, while the metformin-treated diabetic rats (DM + MET) were given a high-fat diet and supplemented with metformin. Biochemical parameters were detected at the end of the test. Expression levels of FXR, CYP8B1, and MAFG were assessed by WB. Serum CA were measured using an enzyme-linked immunosorbent assay (ELISA). Results In HepG2 cells, metformin dose-dependently enhanced the transcriptional activity of FXR and MAFG and inhibited the expression of CYP8B1. Metformin-treated DM rats showed improved glucose and bile acid metabolism. In addition, significantly increased FXR and MAFG and decreased CYP8B1 were observed in DM + MET rats. At the same time, the CA content of metformin-treated rats was lower than that of diabetic rats. Conclusion Changes in CA synthesis after metformin treatment may be associated with inhibition of CYP8B1. These results may play an important role in improving insulin sensitivity after metformin treatment.