Data from surveys show increased mental health disorders in youths. However, little is known about clinical diagnosis over time. To assess the incidence, prevalence, and changes from 2017 to 2021 for depression and anxiety diagnosed clinically among children, adolescents, and young adults and to identify potential disparities. This cohort study included approximately 1.7 million individuals aged 5 to 22 years in Southern California. Data were extracted from electronic medical records; International Statistical Classification of Diseases, Tenth Revision (ICD-10), codes were used to identify depression and/or anxiety diagnosis for each study year from January 1, 2017, to December 31, 2021. Rates were stratified by age, gender, race and ethnicity, estimated household income, weight status, and comorbidity history. Changes over time and association with these variables were assessed using Poisson regression. Data were analyzed between June 1, 2022, and November 29, 2023. Clinical diagnosis of (1) depression and (2) anxiety without a depression diagnosis using ICD-10 codes. Among the 1.7 million participants, mean (SD) age was approximately 14 (5) years, and 51% were male. In terms of race and ethnicity for each study year, approximately 50% of participants were Hispanic; 8%, non-Hispanic Asian; 8%, non-Hispanic Black; and 23%, non-Hispanic White. From 2017 to 2021, depression diagnosis increased by 55.6% (from 1.35% to 2.10%) for incidence and 60.0% (from 2.55% to 4.08%) for prevalence; anxiety without depression diagnosis increased by 31.1% (from 1.77% to 2.32%) for incidence and 35.2% (from 3.13% to 4.22%) for prevalence (P < .001 for trend). The increases in rates were higher during the COVID-19 pandemic (2020-2021) than before the pandemic (2017-2019), except for depression incidence. Rates increased across all subgroups. Rates were highest for subgroups aged 14 to 17 and 18 to 22 years; female participants; those of non-Hispanic American Indian or Alaska Native, non-Hispanic White, or multiple races or ethnicities; and subgroups with higher household income, obesity (and underweight for anxiety without depression), or comorbidities. Among these factors, age was the most important factor for depression diagnosis, whereas weight status was the most important factor for anxiety without depression diagnosis. This cohort study, using electronic medical record data from a large integrated health care system, found an increase in clinically diagnosed depression from 2017 to 2021, with a higher increase during the COVID-19 pandemic and higher rates in some subgroups. Equally important, this study identified high rates and an increase in clinical diagnosis of anxiety without a depression diagnosis. These results support the increased need in public health and health care effort to combat the mental health crisis in youths.