Digital transformation gives new impetus to corporate growth and influences corporate behavior. This study uses hand-collected digital transformation data on A-share listed non-financial enterprises in China from 2008 to 2019 to examine the relationship between corporate digital transformation and tax avoidance. Our findings suggest that the higher the corporate digital transformation, the lower the level of tax avoidance. This impact is more pronounced in firms with high equity incentives for management, a management team with a strong political background, and in firms located in provinces with a high willingness for government intervention and financial pressure from the government. The mechanism test shows that corporate digital transformation mainly decreases tax avoidance by reducing the agency costs of management and increasing media and analysts' attention to the firm. Thus, actively promoting digital transformation is one of the most important paths for guaranteeing a real and stable source of national tax revenue.