Faults in the various electrical and mechanical components of a fuel cell system can affect system reliability and durability. In this study, machine learning was used to accurately diagnose 18 faults in a proton exchange membrane fuel cell system. These faults included those in the thermal management system, first cooling line, second cooling line, air supply system, and water management system. Among the random forest, support vector machine, extreme gradient boosting, light gradient boosting machine, and deep neural network algorithms, the deep neural network model exhibited the highest accuracy in model training. Before diagnosing the 18 faults, a pipeline scenario was introduced to address the data imbalance between normal and fault data and to distinguish between normal and fault conditions. A state-based data distribution method proposed to mitigate data imbalance among fault states achieved an F1-score of 0.987 (accuracy of 98.4%) and 0.942 (accuracy of 94.2%) for fault detection and diagnosis, respectively. Misdiagnosed cases were analyzed by considering the physical characteristics of the system. Additionally, a study on training strategies, prediction of data for operating conditions not included in the training process, for designing datasets for machine learning models revealed an F1score greater than 0.9. This result showed the generality of the model and provided a reference for designing efficient training datasets based on operating conditions.