The study analyzed 1,580 tuberculosis patients to distinguish pulmonary tuberculosis from extrapulmonary tuberculosis (EPTB) using machine learning. They selected seven routine blood markers (BASO, HB, MCHC, MCV, MPV, RBC, RDW-CV), one cytokine IL-6 and three lymphocyte indices (CD4+ T cells, CD4+/CD8+ T cells, CD8+ T cells). They used nine machine learning algorithms to construct predictive models. The best was the K-Nearest Neighbors (KNN) model with an AUC of 0.846, a sensitivity of 0.769 and a specificity of 0.786. The most important markers were CD4+ T cells, HB and MPV. A model based on routine laboratory tests helps in the early diagnosis of EPTB.