H2AFX can play a central role in DNA repair, replication, transcription regulation, and chromosomal stability. However, there is little research to explore the expression of H2AFX in cancers. Moreover, the correlation between the expression of H2AFX and tumor immunity, which affects the prognosis of hepatocellular carcinoma (HCC), is not clear. This article aimed to observe the correlation between H2AFX and tumor tissue infiltration biomarkers in HCC and its prognostic potential in HCC. Oncomine and TIMER database were used to assess the expression level of H2AFX mRNA, and GEPIA and Kaplan-Meier databases were used to evaluate its prognostic potential. The TIMER database analyzed the relationship between h2afx expression level and tumor immune cell infiltration markers in liver cancer tissues. The results showed that H2AFX was overexpressed in tumor tissues than normal tissues in HCC via analysis, and its expression level was correlated with the survival rate of HCC. Moreover, the expression level of H2AFX was related to various immune biomarkers. These results show that overexpression of H2AFX would reflect the poor prognosis of HCC, and these would also reflect that the gene H2AFX can affect the infiltration of HCC immune cells and then play a role in regulating tumor immunity. Our study showed that the gene H2AFX might be a potential poor prognostic biomarker in HCC and might be involved in the infiltration of HCC immune cells.