Caffeine is often used to reduce sleepiness; however, research suggests that it can also cause poor sleep quality. The timing of caffeine use, amongst other factors, is likely to be important for the effects it has on sleep quality. In addition, individual differences exist in the effect of caffeine on sleep quality. This cross‐sectional study investigated the influence of the timing of caffeine consumption on and a possible moderating role of chronotype in the relationship between caffeine consumption and sleep quality in 880 students (74.9% female, mean age 21.3 years, SD = 3.1). Respondents filled in online questionnaires about chronotype (the Morningness–Eveningness Questionnaire), sleep quality (the Pittsburgh Sleep Quality Index) and caffeine consumption. Mean caffeine consumption was 624 mg per week, and 80.2% of the sample drank caffeine after 18:00 hours. Regression analyses demonstrated that higher total caffeine consumption was only related to poorer sleep quality for people who did not drink caffeine in the evening (β = 0.209, p = .006). We did not find a relationship between caffeine and sleep quality in people who drank caffeine in the evening (β = −0.053, p = .160). Furthermore, we found no evidence for a moderating role of chronotype in the relationship between caffeine consumption and sleep quality. We concluded that a self‐regulating mechanism is likely to play a role, suggesting that students who know that caffeine negatively affects their sleep quality do not drink it in the evening. Caffeine sensitivity and the speed of caffeine metabolism may be confounding variables in our study