Background: The close relationship between colorectal cancer and inflammation has been widely reported. However, the relationship between colorectal cancer and inflammation at the genetic level is not fully understood. From a genetic perspective, this study explored the relationship between inflammation-related genes and the immune microenvironment in colorectal cancer.Method: We identified prognostic genes, namely CX3CL1, CCL22, SERPINE1, LTB4R, XCL1, GAL, TIMP1, ADIPOQ, and CRH, by using univariate and multivariate regression analyses. A risk scoring model for inflammatory response was established, and patients in The Cancer Genome Atlas (TCGA) database and Gene Expression Omnibus (GEO) database were divided into two groups: high risk group and low risk group. Result: The analysis showed that the prognosis of the two groups was significantly different, and the low-risk group had a higher survival rate and longer survival time. Pathways related to apoptosis, inflammatory response, and hypoxia were significantly enriched as shown via Gene Set Enrichment Analysis (GSEA). Activated dendritic cell infiltration was found in both the TCGA and GEO databases, and the CCL21 gene played a significant role in the process of activated dendritic cell infiltration. CCL21 gene was also positively correlated with inflammatory response, and the gene expression and risk score were significantly different between the two groups.Conclusion: In summary, inflammatory response has a direct impact on patients with colorectal cancer in the prognosis and immune infiltration and further research studies on the inflammatory response can help in advancing the development of immunotherapy for colorectal cancer.