In the current study the effects of metformin and cyanidin on the immune system and intestinal flora in rats with type-2 diabetes was investigated. The findings showed that metformin or cyanidin treatment considerably reduced the rise in body weight and glucose levels induced by type-2 diabetes. The type-2 diabetic rats' glucose tolerance was significantly increased by cyanidin administration comparable to that of metformin. Cyanidin administration resulted in a significant reduction in serum cholesterol and low-density lipoprotein (LDL) levels in rats with type-2 diabetes. Treatment with cyanidin significantly increased the ratio of high-density lipoprotein to low-density lipoprotein in type-2 diabetes rats. Cyanidin administration significantly raised the ratio of Firmicutes to Bacteroidetes in the fecal samples of type-2 diabetic rats compared to the model group. In comparison to the model group, it also significantly raised the levels of Lactobacillus intestinalis, Lactobacillus gasseri, and Lactobacillus reuteri in the type-2 diabetes rats. In type-2 diabetes rat fecal samples, the abundance of Christensenellaceae significantly increased while Enterobacteriaceae and Proteobacteria were found to decrease upon cyanidin administration. Furthermore, cyanidin administration to the rats with type-2 diabetes significantly improved the glucose homeostasis. In conclusion, the study demonstrates that cyanidin enhances glucose homeostasis in rats with type-2 diabetes, potentially through controlling intestinal flora. Thus, cyanidin may be looked into more as a possible therapeutic agent for type 2 diabetes.