Objective: To investigate the correlation between the expression of glucose-6-phosphate dehydrogenase (G6PD) and the clinicopathological characteristics, prognosis and immune cell infiltration of hepatocellular carcinoma (HCC). Methods: The expression of G6PD in liver cancer tissues and normal tissues is extracted from TCGA and GEO databases, validated by immunohistochemistry, and the correlation between G6PD expression and clinical features is analyzed. The clinical significance of G6PD in liver cancer is assessed by Kaplan-Meier, Cox regression, and prognostic line graph models. Functional enrichment analysis is performed by protein-protein interaction (PPI) network, GO/KEGG, GSEA and for G6PD-associated differentially expressed genes (DEGs). TIMER and ssGSEA packages are used to assess the correlation between expression and the level of immune cell infiltration. Results: Analysis of TCGA and GEO datasets revealed that G6PD expression is significantly upregulated in hepatocellular carcinoma tissues (P < 0.001). G6PD expression is associated with histological grade, pathological stage, T-stage, vascular infiltration, and AFP level (P < 0.05); HCC patients in the low G6PD expression group had longer overall survival and better prognosis compared with the high G6PD expression group (P < 0.05). The level of G6PD expression affects the levels of macrophages, dendritic cells, B cells, and follicular helper T cells in the tumor microenvironment. Conclusion: High expression of G6PD is a potential biomarker for poor prognosis of hepatocellular carcinoma, and G6PD may be a target for immunotherapy of HCC.