Abstract Background Accumulating evidence indicates that type II cystatin (CST) genes play a pivotal role in several tumor pathological processes, thereby affecting all stages of tumorigenesis and tumor development. However, the prognostic and predictive value of type II CST genes in GC has not yet been investigated. Methods The present study evaluated the expression and prognostic value of type II CST genes in GC by using The Cancer Genome Atlas (TCGA) database and the Kaplan–Meier plotter (KM plotter) online database. The type II CST genes related to the prognosis of GC were then screened out. We then validated the expression and prognostic value of these genes by immunohistochemistry. We also used Database for Annotation, Visualization, and Integrated Discovery (DAVID), Gene Multiple Association Network Integration Algorithm (GeneMANIA), Search Tool for the Retrieval of Interacting Genes/Proteins (STRING), nomogram, genome-wide co-expression analysis, and other bioinformatics tools to analyze the value of type II CST genes in GC and the underlying mechanism. Results The data from the TCGA database and the KM plotter online database showed that high expression of CST2 and CST4 was associated with the overall survival (OS) of patients with GC. The immunohistochemical expression analysis showed that patients with high expression of CST4 in GC tissues have a shorter OS than those with low expression of CST4 (HR = 1.85,95%CI: 1.13–3.03, P = 0.015). Multivariate Cox regression analysis confirmed that the high expression level of CST4 was an independent prognostic risk factor for OS. Conclusions Our findings suggest that CST4 could serve as a tumor marker that affects the prognosis of GC and could be considered as a potential therapeutic target for GC.