Gut microbiota plays an important role in health and disease. To determine whether the traditional Chinese formula Zi Huang Huo Xiang San (ZHHXS) modulates gut microbiota under heat stress, a heat stress model was prepared in Roman layer hens by housing them at temperatures of 32–36°C and administering ZHHXS for 4 weeks. The Roman egg layers were randomly divided into three groups with 10 hens in each: a ZHHXS treatment group (ZHHXS-HS), a heat-stressed group (HS), and a blank control group (BC). The ZHHXS-HS and HS groups were housed in a 34 ± 2°C environment, while the BC group was housed at 25 ± 1°C. The ZHHXS-HS hens were fed a diet supplemented with 1% ZHHXS from 1 to 28 days, while the other groups were not. Gut microbiota in the hens' feces was assessed through 16S rRNA high-throughput sequencing on days 1, 3, 7, 14, and 28. A plot of the PCA scores showed that the gut microbiota composition in the BC group was a similar trend in the ZHHXS-HS group on days 1 and 3. The principal coordinate analysis (PCoA) unweighted distribution showed that the gut microbiota composition had no significant differences between the BC and ZHHXS-HS groups on days 1 and 7. The PCoA weighted distribution showed that the gut microbiota composition had no significant differences between the BC and ZHHXS-HS groups on days 1 and 3. This study showed that the composition of gut microbiota in layer hens with heat stress was modulated by ZHHXS treatment. ZHHXS treatment caused key phylotypes of gut microbiota to match the BC group, particularly Actinobacteria, Bacteroidetes, Bacteroides, and Enterococcus. The effect of ZHHXS in alleviating heat stress could be achieved by altering the composition of gut microbiota and regulating some key phylotypes.