An accurate deep learning predictor of enzyme optimal pH is essential to quantitatively describe how pH influences the enzyme catalytic activity. CatOpt, developed in this study, outperformed existing predictors of enzyme optimal pH (RMSE = 0.833 and R2 = 0.479), and could provide good interpretability with informative residue attention weights. The classification of acidophilic and alkaliphilic enzymes and prediction of enzyme optimal pH shifts caused by point mutations showcased the capability of CatOpt as an effective computational tool for identifying enzyme pH preferences. Furthermore, a single point mutation designed with the guidance of CatOpt successfully enhanced the activity of Pyrococcus horikoshii diacetylchitobiose deacetylase at low pH (pH = 4.5/5.5) by approximately 7%, suggesting that CatOpt is a promising in silico enzyme design tool for pH-dependent enzyme activities.