BackgroundThe gut microbiota plays an essential role in maintaining gut homeostasis and improving performance, with the composition of microbial communities visibly differing across different laying stages in hens and significantly correlating with egg production. To gain further insights into the association between microbial community characteristics and laying periods in Hy-Line variety brown and Isa brown laying hens, we conducted a 16S rRNA amplicon sequencing survey.ResultsOur result revealed the diversity of bacteria in the early laying period was commonly higher than peak, and in Hy-Line variety brown laying hens were generally higher than Isa brown. Principal coordinate analysis (PCoA) and permutational multivariate analysis of variance (PERMANOVA) revealed that the structure and composition of the gut microbiota of laying hens exhibited significant differences among different groups. PhylumFirmicutes,Bacteroidota,Proteobacteria, andFusobacteriotawere found that dominant in the host’s feces. Therein, the abundance ofFusobacteriotawas higher in the peak period than in the early period, while the abundance ofCyanobacteriain the early period was higher in two breeds of hens. Furthermore, random forest based on machine learning showed that there were several distinctly abundant genera, which can be used as potential biomarkers to differentiate the different groups of laying periods and breeds. In addition, the prediction of biological function indicated the existing discrepancy in microbial function among the microbiota of four groups.ConclusionsOur findings offer new insights into the bacterial diversity and intestinal flora composition of different strains of laying hens during various laying periods, contributing significantly to the improvement of production performance and the prevention of chicken diseases.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12866-023-02857-2.