Objective. The aim of this study is to investigate the implication of the Chinese herbal formula (CHF) Shenzhu tiaopi Granule (STG) in type 2 diabetes mellitus (T2DM) and discuss the mechanisms by which STG regulates the gut microbiota. Method. Goto-Kakizaki (GK) rats and age-matched Wistar (W) rats were acclimatized for 1 week. The GK rats were randomly divided into 3 groups and orally gavaged with saline (model group, M), acarbose (acarbose group, A), and STG (granule of CHF group, G; the component of this formula includes Codonopsis pilosula, Rhizoma Atractylodis, Pinellia, Poria cocos, Pericarpium Citri Reticulatae, Coptis chinensis Franch, and Pueraria). The W rats were orally gavaged with saline (control group, C). The observation time was 8 weeks. The weight, fasting blood glucose (FBG) level, and blood lipid levels were tested. The 16S rRNA genes in the V3-V4 region were sequenced, and the structure of the gut microbiota was analysed. Results. Compared to C, M displayed significant differences in blood glucose, gut microbiota, etc. (P<0.05; P<0.01). Compared to M, A and G showed a similar reduction in the FBG gain and a shift in the structure of the gut microbiota (P<0.05; P<0.01). Compared with A, G exhibited a significant decrease in weight, FBG level, and total cholesterol (P<0.05). The gut microbiota, Bacteroidetes, the Firmicutes/Bacteroidetes ratio, Allobaculum, and Desulfovibrionaceae were significantly decreased in response to the STG treatment, while Lactobacillus was significantly enriched (P<0.05; P<0.01). The community composition also differed at the phylum and genus levels based on the linear discriminant analysis effect size and heat map. Conclusion. Our findings suggest that the composition of the gut microbiota was significantly changed in the diabetic GK rats compared with that in the normal W rats. STG treatment can improve glucose and lipid levels and modulate the gut microbiota in T2DM rats.