Chronic hepatitis B (CHB) is a major public health problem in the world. It is the main cause of liver cirrhosis and liver cancer. Although many important roles of RNA modification in stem cells or tumor diseases have been identified, the role of N7-methylguanosine (m7G) modification in the process of chronic HBV infection has not been clearly defined. Therefore, we conducted a systematic analysis on the process of chronic HBV infection. We found that a total of 18 m7G-related genes were altered in chronic HBV infection, and then we screened out CHB potential diagnostic biomarkers using machine learning and random forest methods. RT-qPCR was performed on the samples of healthy people and CHB, which further verified the possibility of being a diagnostic marker. Then, we typed CHB patients based on these 18 genes. We found that the immune microenvironment of different subtypes was different. Among them, patients with subtype-Ⅰ had severe immune response, that is, relatively serious immune cell infiltration, rich immune pathways, relatively many HLA genes, and immune checkpoints. Finally, we conducted an in-depth discussion on our m7G-related genes, and found that m7G gene related to immune cell infiltration may be involved in the disease progression of CHB patients, which was also confirmed in the GSE84044 dataset. In conclusion, m7G-related genes can not only serve as diagnostic markers of CHB, but also participate in the regulation of immune microenvironment and play an important role in the progression of CHB.