BackgroundHepatocellular carcinoma (HCC) is the third leading cause of cancer-related deaths worldwide, and is characterized by insidious onset, rapid progression, and poor prognosis. Immunotherapy is a first-line treatment for advanced HCC. The identification of immune-related prognostic markers may be an effective strategy to predict and improve clinical response rate of immunotherapy.MethodsThe DESeq2, edgeR, and limma R packages were used to compare the transcriptomes of HCC with different prognoses. Cancer-related databases such as UALCAN, TNMplot, GEPIA, muttarget and Human Protein Atlas (HPA), and the Kaplan–Meier Plotter platform were used to analyze the relationship between CLDN18 and the clinical characteristics, as well as prognosis of HCC. The co-expressed genes of CLDN18 were obtained from LinkedOmics platform, and GO functional enrichment and KEGG pathway analysis were performed. The CIBERSORT, TIMER, Timer 2.0 and TISIDB algorithms were used to analyze immune infiltration.ResultsCLDN18 was differentially expressed in HCC patients with different prognoses, and its expression level in PBMC was positively correlated with the stage of BCLC. In addition, CLDN18 was significantly overexpressed in HCC tumor tissues compared to adjacent non-tumor tissues, which was consistent with PBMC sequencing results and immunohistochemical data from human protein profiles. CLDN18 was also positively correlated with HCC staging and grading, and high expression levels of CLDN18 predicted shorter overall survival. Functional annotation of CLDN18 in HCC revealed enrichment of the cellular senescence and protein activation cascade, along with biological processes such as cell cycle, inflammatory response, and cellular ketone metabolism. In addition, CLDN18 was also associated with tumor infiltrating immune cells, suppressive immune cell markers, T lymphocyte depletion and activation of HCC, and low expression of CLDN18 was associated with higher CD8 + T cell infiltration and better survival rates.ConclusionsCLDN18 is a potential prognostic marker and immunotherapeutic target for HCC.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12876-023-02843-y.