Coronavirus pandemic (COVID-19) is an infectious illness. A newly explored coronavirus caused it. Currently, more than 112 million verified cases of COVID-19, containing 2,4 million deaths, are reported to WHO (February 2021). Scientists are working to develop treatments. Early detection and treatment of COVID-19 are critical to fighting disease. Recently, automated systems, specifically deep learningbased models, address the COVID-19 diagnosis task. There are various ways to test COVID-19. Imaging technologies are widely available, and chest X-ray and computed tomography images are helpful. A publicly available dataset was used in this study, including chest X-ray images of normal, COVID-19, and viral pneumonia. Firstly, images were preprocessed. Three deep learning models, namely DarkNet-53, ResNet-18, and Xception, were used in feature extraction from images. The number of extracted features was decreased by Binary Particle Swarm Optimization. Lastly, features were classified using Logistic Regression, Support Vector Machine, and XGBoost. The maximum accuracy score is 99.7% in a multi-classification task. This study reveals that pre-trained deep learning models with a metaheuristic-based feature selection give robust results. The proposed model aims to help healthcare professionals in COVID-19 diagnosis.