Real-time testing of coal ash plays a vital role in the chemical, power generation, metallurgical, and coal separation sectors. The rapid online testing of coal ash using radiation measurement as the mainstream technology has problems such as strict coal sample requirements, poor radiation safety, low accuracy, and complicated equipment replacement. In this study, an intelligent detection technique based on feed-forward neural networks and improved particle swarm optimization (IPSO-FNN) is proposed to predict coal quality ash content in a fast, accurate, safe,and convenient manner. The data set was obtained by testing the elemental content of 198 coal samples with X-ray fluorescence (XRF). The types of input elements for machine learning (Si, Al, Fe, K, Ca, Mg, Ti, Zn, Na, P) were determined by combining the X-ray photoelectron spectroscopy (XPS) data with the change in the physical phase of each element in the coal samples during combustion. The mean squared error and coefficient of determination were chosen as the performance measures for the model. The results show that the IPSO algorithm is useful in adjusting the optimal number of nodes in the hidden layer. The IPSO-FNN model has strong prediction ability and good accuracy in coal ash prediction. The effect of the input element content of the IPSO-FNN model on the ash content was investigated, and it was found that the potassium content was the most significant factor affecting the ash content. This study is essential for real-time online, accurate, and fast prediction of coal ash.