The advent of an inclusive digital economy in China has reshaped urban dynamics, prompting shifts in resource reliance and altering energy consumption patterns. Given this, we conduct city-level data analysis to elucidate the intricate relationship between this digital transformation and changes in the urban energy mix from 2011 to 2022. This study provides an in-depth empirical analysis of how the digital economy (DE) affects the urban energy mix and explores the possible mechanisms of action behind it. The findings of the study are as follows: first, DE positively promotes the changes in the urban energy mix (CUEM); second, the promotion effect of DE on the urban energy mix is more obvious in southern cities, fifth-tier cities, cities with relatively low public environmental concern and higher degree of marketization; and third, the core mechanism indicates that DE promotes the change of urban energy structure by weakening the city's resource dependence (RSD). These findings provide valuable recommendations for city managers and policy makers, emphasizing that the importance of DE in the modern economic context is not limited to the economic realm, but also lies in its potential value in promoting environmental sustainability and social well-being.