As the fastest-growing form of land use, urbanization drives profound environmental change that reshapes biodiversity. Studies in urban ecology and evolution often rely on generic indices of urbanization to characterize biodiversity patterns along urban-rural gradients. However, these indices do not permit explicit tests of causal hypotheses by which urbanization mediates ecological and evolutionary processes. Here, we show how a graphical causal modeling framework with directed acyclic graphs (DAGs) can be used to design clear conceptual models to better evaluate mechanistic hypotheses about the effects of urbanization on biodiversity. We introduce the basic structure of DAGs and illustrate their value, first with simulated data and then with a case study on coat color variation in eastern gray squirrels (Sciurus carolinensis) along an urbanization gradient in Syracuse, New York, USA. We show how univariate statistical models with generic urbanization predictors are difficult to interpret and can lead to misleading conclusions about mechanisms in urban ecology and evolution. In contrast, DAGs make causal assumptions transparent and can point to specific processes driving biodiversity patterns. When applied to our case study, analyses informed by a DAG revealed a surprising finding: although squirrel melanism was more prevalent in urban than rural populations, the prevalence of melanism was constrained by components of environmental change common to cities, namely roads, forest loss, and predator activity, in contrast to expectations. Managing biodiversity in an increasingly urbanized world will require a mechanistic understanding of how urbanization impacts biodiversity patterns; graphical causal models can provide a powerful approach to do so.