BackgroundHepatitis B virus (HBV) causes chronic hepatitis B (CHB), liver cirrhosis, and hepatocellular carcinoma. The evolution of human gut microbiota during the progression of HBV-related liver diseases remains unclear. Therefore, we prospectively enrolled patients with HBV-related liver diseases and healthy individuals. Through 16S ribosomal RNA amplicon sequencing, we characterized the gut microbiota of the participants and predicted the functions of microbial communities.ResultsWe analyzed the gut microbiota of 56 healthy controls and 106 patients with HBV-related liver disease [14 with resolved HBV infection, 58 with CHB, and 34 with advanced liver disease (15 with liver cirrhosis and 19 with hepatocellular carcinoma)]. Patients with HBV-related liver disease exhibited a higher degree of bacterial richness (allP< 0.05) than did healthy controls. Beta diversity analyses revealed a distinct clustering pattern between healthy controls and patients with HBV-related liver disease (allP< 0.05). The composition of bacteria (from the phylum level to the genus level) varied across the stages of liver disease. Linear discriminant analysis effect size revealed multiple taxa that differ significantly in abundance between healthy controls and patients with HBV-related liver disease; however, fewer differences were observed among patients with resolved HBV infection, those with CHB, and those with advanced liver disease. The ratio of Firmicutes to Bacteroidetes was increased in all three patient groups compared with the ratio in healthy controls (allP< 0.001). The analysis of the sequencing data by using PICRUSt2 revealed the changes in microbial functions with disease progression.ConclusionsThe diversity and composition of gut microbiota appear to vary significantly between healthy controls and patients at different stages of HBV-related liver disease. The understanding of gut microbiota may provide novel therapeutic options in these patients.Supplementary InformationThe online version contains supplementary material available at 10.1186/s13099-023-00549-w.