A heterocyclic derivative represented by formula (I), or a pharmaceutically acceptable salt or a stereoisomer thereof, which has an inhibitory effect on the activation of STAT3 protein, and is useful for the prevention or treatment of diseases associated with the activation of STAT3 protein.