5-HT<sub>7</sub>R belongs to a family of G protein-coupled receptors and is associated with a variety of physiological processes in the central nervous system via the activation of the neurotransmitter serotonin (5-HT). To develop selective and biased 5-HT<sub>7</sub>R ligands, we designed and synthesized a series of pyrazolyl-diazepanes <b>2</b> and pyrazolyl-piperazines <b>3</b>, which were evaluated for binding affinities to 5-HTR subtypes and functional selectivity for G protein and β-arrestin signaling pathways of 5-HT<sub>7</sub>R. Among them, 1-(3-(3-chlorophenyl)-1<i>H</i>-pyrazol-4-yl)-1,4-diazepane <b>2c</b> showed the best binding affinity for 5-HT<sub>7</sub>R and selectivity over other 5-HTR subtypes. It was also revealed as a G protein-biased antagonist. The self-grooming behavior test was performed with <b>2c</b> in vivo with Shank3<sup>-/-</sup> transgenic (TG) mice, wherein <b>2c</b> significantly reduced self-grooming duration time to the level of wild-type mice. The results suggest that 5-HT<sub>7</sub>R could be a potential therapeutic target for treating autism spectrum disorder stereotypy.