Molecular design of small-molecule inhibitors targeting programmed cell death-1 (PD-1)/programmed cell death ligand-1 (PD-L1) pathway has been recognized as an active research area by the clinical success of cancer immunotherapy. In recent years, using machine learning (ML) methods to accelerate drug design have been confirmed. However, the black box character of ML methods makes model interpretation and ligands optimization obscured. Herein, five explainable ML models were constructed by integrating five ML models with the SHAP method, where these ML models were pretrained with >4000 molecules and their R2 ranged from 0.835 to 0.86 on test set. Subsequently, the explainable ML models were employed to identify the relationship between fragments and bio-activity of a small molecule inhibitor BMS-1166, leading to the modification of BMS-1166 into 60 novel compounds. After consensus docking and ADMET test, 3 small molecules (C27, C52 and C54) with better docking scores and lower toxicity than BMS-1166 were screened out further. Finally, the improved binding affinity of C27, C52 to the PD-L1 dimer was validated by the MD simulation. Overall, this work proposed an efficient protocol on the basis of explainable ML models for designing small-molecule inhibitors targeting PD-1/PD-L1 pathway in a rational way.