In epidemiological research, the link between coffee consumption and bone mineral density (BMD) is still debated. Moreover, there hasn't been any research on the relationship between urine caffeine and caffeine metabolites and BMD. This study aimed to investigate if there was a connection between urine caffeine and its metabolites and BMD in people between the ages of 8 and 19. Using data from the National Health and Nutrition Examination Survey 2009 to 2014, multivariate logistic regression models were utilized to investigate the association between urinary caffeine and caffeine metabolites and total BMD. Fitted smoothing curves and generalized additive models were also used. A total of 1235 adolescents were included in this analysis, after controlling for various variables, we found that the association between urinary theophylline and total BMD was negative, whereas the association between urinary paraxanthine, theobromine and caffeine and total BMD was positive. In our study, an inverted U-shaped association between urinary paraxanthine and urinary caffeine was found with BMD in women. In this cross-sectional study, the correlation between urinary caffeine and its metabolites and total BMD differed by sex and race. More studies are needed to confirm the results of this study and to investigate the underlying causes.