In this paper, small-molecule quaternary ammonium salts were synthesized by N-alkylation to inhibit hydration swelling and hydration dispersion. The prepared small-molecule quaternary ammonium salt was characterized by Fourier transform infrared (FTIR) spectroscopy, Thermogravimetric analysis (TGA), particle size analysis and Scanning electron microscopy (SEM), and its performance as an inhibitor in clay was evaluated by an anti-swelling test and a linear swelling test. The results show that small-molecule quaternary ammonium salt (TEE-2) synthesized by triethanolamine and epichlorohydrin in ethanol with a molar ratio of 1:1.5 can successfully inhibit the hydration swelling and dispersion of clay. The anti-swelling rate of TEE-2 was 84.94%, the linear swelling rate was 36.42%, and the linear swelling rate of 0.5% TEE-2 was only 29.34%. The hydration swelling of clay in 0.5% TEE-2 solution was significantly inhibited. The hydration inhibition mechanism of the small-molecule quaternary ammonium salt inhibitor 0.5% TEE-2 was analyzed by FTIR, SEM and TGA. It was considered that 0.5% TEE-2 has strong hydration inhibition, which was realized by infiltration and adsorption on the clay surface. Small-molecule quaternary ammonium salts were beneficial for maintaining wellbore stability and reducing the risk of wellbore instability.