The present study investigated the impact of corporate violations on corporate charitable donation behavior and the heterogeneity influences played by corporate ownership type, analyst attention and information transparency. This study analyzed 3,715 non-financial companies in Chinese A-shares from 2011 to 2020 using panel data. The impact of corporate violations on corporate charitable donations was examined by using Ordinary Least Squares, instrumental variables two-stage least squares and propensity score matching method. Consequently, the following conclusions are presented. First, corporate violations are significantly positively correlated with the level of corporate charitable donations. Second, among the companies with high analyst attention, high information transparency, or non-state-owned nature, the positive impact of enterprise violations on charitable donations is greater. These findings suggest that charitable giving may be used by some businesses as an undesirable tool to conceal their irregularities. No study has been conducted regarding the influence of corporate violations on corporate charitable donations in China. This study is a pioneering study that seeks to give insights into the link between these variables in the context of China, which has practical implications for gaining insights into corporate charitable giving in China, as well as identifying and curbing “hypocritical” corporate charitable donation behavior.