Having accurate knowledge on CO2 solubility in reservoir liquids plays a pivotal role in geoenergy harvest and carbon capture, utilization, and storage (CCUS) applications. Data-driven works leveraging artificial neural networks (ANN) have presented a promising tool for forecasting CO2 solubility. In this paper, an ANN model was developed based on hundreds of documented data to predict CO2 solubility in both pure water and saline solutions across a broad spectrum of temperatures, pressures, and salinities in reference to underground formation conditions. Multilayer perceptron (MLP) models were constructed for each system, and their prediction results were rigorously validated against the the literature data. The research results indicate that the ANN model is suitable for predicting the solubility of carbon dioxide under different conditions, with root mean square errors (RMSE) of 0.00108 and 0.00036 for water and brine, and a coefficient of determination (R2) of 0.99424 and 0.99612, which indicates robust prediction capacities. It was observed from the ANN model that the saline water case could not be properly expanded to predict the CO2 solubility in pure water, underscoring the distinct dissolution mechanisms in polar mixtures. It is expected that this study could provide a valuable reference and offer novel insights to the prediction of CO2 solubility in complex fluid systems.