Per-and polyfluoroalkyl substances (PFAS) are hazardous chemicals that have been widely used in different industries and released into the environment through contaminated effluents. Nanofiltration (NF) is a promising process for removing PFAS from the effluents. This study aimed to model and analyze the performance of the NF membrane process in perfluorooctanesulfonic acid (PFOS) removal from contaminated effluents using machine learning (ML) algorithms. The modeling output of seven ML algorithms was evaluated using statistical indexes of determination coefficient (R-2) and mean squared error (MSE) for robustness. The results demonstrated that random forest (RF), gradient boosting machine (GBM), and AdaBoost models were the most robust for the NF process. Accordingly, the optimization of these procedures was accomplished using a grid search. The optimized models were deeply analyzed using permutation variable importance (PVI) to quantify the relative importance of operating variables. The three ML procedures (RF, GBM, AdaBoost) presented high prediction strength for PFOS removal from contaminated effluents with low MSE values (4.726, 2.450, 2.879) and high R(2 )values (0.930, 0.975, 0.968). In addition, PVI-RF showed decreasing importance of pressure, initial PFOS concentration, membrane type, trivalent cation, pH, divalent cation and monovalent cation consecutively.