Tuberculosis (TB) is a serious problem worldwide, especially in low and middle-income countries where access to expert radiologists is low. Chest X-ray (CXR) screening is highly popular but manual interpretation is a time-consuming task and is subject to inter-observer variability. This study investigates transformer-based architectures for automated tuberculosis (TB) detection from chest X-ray images. A Swin Transformers model was evaluated with stratified 5-fold cross-validation on a publicly available dataset with 4200 images (700 TB and 3500 normal). To overcome class imbalance, cost-sensitive learning was applied with the use of class-weighted loss functions. On an internal test set held-out of 840 images (700 normal, 140 TB), the Swin Transformer obtained 99.29% accuracy, 0.96 TB sensitivity, 1.00 specificity and a TB F1-score of 0.98. Five fold cross validated performance was stable with narrow confidence interval. Out-of-domain testing on a separate data set of 3,008 images gave 85.17% accuracy, 0.8821 sensitivity, 0.7043 specificity which shows the effects of domain shift. Grad-CAM was carried out to give visual explanations and validate clinically relevant attention. Results suggest the proposed framework is an excellent candidate as a decision support tool for mass screening for TB, provided it is validated in additional multi-center studies and adaptation of the framework to additional domains is conducted.