The present invention relates to a benzamide compound and a preparation method, use, and pharmaceutical composition thereof. The benzamide compound is represented by formula (I), is a STAT3 inhibitor, and can be used to prevent and/or treat a disease related to STAT3 activity, such as a tumor, autoimmune disease, renal disease, cardiovascular disease, inflammation, metabolic/endocrine dysfunction, and neurological disease.