Background. Tuberculosis (TB), caused by the bacterium Mycobacterium tuberculosis, affects approximately one-quarter of the global population and is considered one of the most lethal infectious diseases worldwide. The prevention of latent tuberculosis infection (LTBI) from progressing into active tuberculosis (ATB) is crucial for controlling and eradicating TB. Unfortunately, currently available biomarkers have limited effectiveness in identifying subpopulations that are at risk of developing ATB. Hence, it is imperative to develop advanced molecular tools for TB risk stratification. Methods. The TB datasets were downloaded from the GEO database. Three machine learning models, namely LASSO, RF, and SVM-RFE, were used to identify the key characteristic genes related to inflammation during the progression of LTBI to ATB. The expression and diagnostic accuracy of these characteristic genes were subsequently verified. These genes were then used to develop diagnostic nomograms. In addition, single-cell expression clustering analysis, immune cell expression clustering analysis, GSVA analysis, immune cell correlation, and immune checkpoint correlation of characteristic genes were conducted. Furthermore, the upstream shared miRNA was predicted, and a miRNA–genes network was constructed. Candidate drugs were also analyzed and predicted. Results. In comparison to LTBI, a total of 96 upregulated and 26 downregulated genes related to the inflammatory response were identified in ATB. These characteristic genes have demonstrated excellent diagnostic performance and significant correlation with many immune cells and immune sites. The results of the miRNA–genes network analysis suggested a potential role of hsa-miR-3163 in the molecular mechanism of LTBI progressing into ATB. Moreover, retinoic acid may offer a potential avenue for the prevention of LTBI progression to ATB and for the treatment of ATB. Conclusion. Our research has identified key inflammatory response-related genes that are characteristic of LTBI progression to ATB and hsa-miR-3163 as a significant node in the molecular mechanism of this progression. Our analyses have demonstrated the excellent diagnostic performance of these characteristic genes and their significant correlation with many immune cells and immune checkpoints. The CD274 immune checkpoint presents a promising target for the prevention and treatment of ATB. Furthermore, our findings suggest that retinoic acid may have a role in preventing LTBI from progressing to ATB and in treating ATB. This study provides a new perspective for differential diagnosis of LTBI and ATB and may uncover potential inflammatory immune mechanisms, biomarkers, therapeutic targets, and effective drugs in the progression of LTBI into ATB.