Previous studies revealed that consuming spicy food reduced mortality from CVD and lowered stroke risk. However, no studies reported the relationship between spicy food consumption, stroke types and dose–response. This study aimed to further explore the association between the frequency of spicy food intake and the risk of stroke in a large prospective cohort study. In this study, 50 174 participants aged 30–79 years were recruited. Spicy food consumption data were collected via a baseline survey questionnaire. Outcomes were incidence of any stroke, ischaemic stroke (IS) and haemorrhagic stroke (HS). Multivariable-adjusted Cox proportional hazard models estimated the association between the consumption of spicy food and incident stroke. Restricted cubic spline analysis was used to examine the dose–response relationship. During the median 10·7-year follow-up, 3967 strokes were recorded, including 3494 IS and 516 HS. Compared with those who never/rarely consumed spicy food, those who consumed spicy food monthly, 1–2 d/week and 3–5 d/week had hazard ratio (HR) of 0·914 (95 % CI 0·841, 0·995), 0·869 (95 % CI 0·758, 0·995) and 0·826 (95 % CI 0·714, 0·956) for overall stroke, respectively. For IS, the corresponding HR) were 0·909 (95 % CI 0·832, 0·994), 0·831 (95 % CI 0·718, 0·962) and 0·813 (95 % CI 0·696, 0·951), respectively. This protective effect showed a U-shaped dose–response relationship. For obese participants, consuming spicy food ≥ 3 d/week was negatively associated with the risk of IS. We found the consumption of spicy food was negatively associated with the risk of IS and had a U-shaped dose–response relationship with risk of IS. Individuals who consumed spicy food 3–5 d/week had a significantly lowest risk of IS.