Introduction: Maintaining and improving prisoners' health and their rehabilitation can be effective steps towards eliminating health inequalities and approaching the UN's Sustainable Development Goals. Accordingly, identifying protective factors and health barriers of this vulnerable group and changing the prison into an environment that can deliver health interventions tailored to the needs of inmates can provide the basis for attaining justice in health. Purpose: This study builds on an artificial neural network model to determine the effect of demographic, psychological, criminological, and physical activity factors on prisoners' general health. Methods: The study detected the patterns between variables using a neural network with nine inputs and one output. To determine the neural network with the minimum sum of squared errors, we evaluated the performance of all neural networks using varying algorithms and numbers of neurons in the hidden layer. For this purpose, the analysis of the data of 149 prisoners aged between 16 and 61 years was performed using SPSS-22 software. Results: The optimal neural network model was useful in predicting prisoners' general health. In this model, the variables of occupation, life expectancy, age, and hope of acceptance were identified as the first most significant factors with 19.25, 17.45, 15.98, and 15.16 percentages, respectively, whereas the cause of incarceration, education level, type of drug misuse, and physical activity were the second most important factors with 8.82, 8.38, 7.91, and 7.04 percentages, respectively. Conclusion: Experiencing psychosocial pressures related to incarceration is more severe for the marginalized and disadvantaged individuals, persons in very young or old age ranges, and those with no history of incarceration, which can increase the likelihood of impaired health for these inmates. Consideration of the prisoners' needs in proportion to their characteristics and provision of emotional and spiritual support of the inmates, especially in the early stages of incarceration, can help shape an effective adjustment process and select appropriate and efficient strategies.