Interleukin-21 (IL-21) is an important antitumor cytokine that contributes to the proliferation and differentiation of CD8 + T cells. It has been proven to enhance the response to immune checkpoint inhibitors (ICIs) in various solid tumors. However, its role in hepatocellular carcinoma (HCC) has not yet been clarified. In this research, we aimed to investigate the antitumor effect of IL-21 in HCC and its effect on ICI treatment. Through transcriptome sequencing analysis and immunohistochemistry validation, we found that patients with high IL-21 expression had a better prognosis. HCCs with high expression of IL-21 had higher infiltration of CD8 + T cells, increased expression of immune checkpoints, and an improved response to ICI treatment. In conclusion, IL-21 can enhance the efficacy of ICI treatment and improve the prognosis of patients by promoting the infiltration of CD8 + T cells and the expression of immune checkpoint-related genes.