Shale swelling poses considerable challenges for companies involved in extended-reach well drilling, particularly when it comes to maintaining wellbore stability. Despite the incorporation of swelling inhibitors in water-based drilling fluids (WBDFs), shale swelling can persist as an issue. Currently, the assessment of WBDFs' ability to prevent swelling usually involves costly, timeconsuming, and labor-intensive laboratory experiments. Therefore, this study leverages machine learning techniques (ML) to forecast the dynamic linear swelling behavior of sodium bentonite-based shale wafers. These shale wafers were subjected to different WBDFs containing diverse inorganic salts such as sodium chloride (NaCl), potassium chloride (KCl), magnesium chloride (MgCl 2 ), and calcium chloride (CaCl 2 ). To gather sufficient data to train the ML models, an extensive experimental study was conducted using various WBDF formulations. The experiments were conducted on wafers, wherein each wafer treated with an inorganic salt underwent a linear swell test for 120 h until the swelling reached a plateau. Moreover, the conductivities and zeta potential of WBDFs, which were prepared using varying concentrations of salts, were recorded. Several ML techniques, namely gradient boosting, decision trees, adaptive gradient boosting (AdaBoost), K-nearest neighbors, random forest, extreme gradient boosting, and stacked generalized regression (SGR) were used to forecast shale swelling. The ML models were trained using input features such as salt types, salt concentrations, salt conductivities, salt zeta potential, and elapsed time. The results revealed that the SGR model outperformed other techniques by effectively predicting linear swelling in terms of coefficient of determination (R 2 ) above 0.95. The developed ML model offers an efficient approach to assess the maximum swelling potential of various WBDFs that can help in effectively mitigating the wellbore instability concerns by continuously evaluating the interaction between shale and the drilling fluid for drilling for extended reach or maximum contact wells.