This study aimed to verify the association between the community food environment and dietary patterns in a population of different socio-economic levels. This cross-sectional study was conducted with a sample of 400 adults and elderly aged between 20 and 70 years residing in the central area of Porto Alegre, Rio Grande do Sul. Four dietary patterns were explored: healthy, traditional Brazilian, refined carbohydrates and sugars, and fast food. The community food environment included the identification of all food stores by areas where individuals lived and auditing based on the Nutrition Environment Measures Survey in Stores (NEMS-S) score. Poisson regression was used to estimate the prevalence ratios (PR) and their respective 95 % CI. After the adjustment for individual sociodemographic characteristics, residents of the area with the best community food environment (highest NEMS-S score) had 12 % and 18 % lower probabilities of high consumption (upper tertile) of the traditional (PR = 0·88; 95 % CI (0·78, 0·98)) and refined carbohydrate and sugar (PR = 0·82; 95 % CI (0·73, 0·92)) dietary patterns, respectively, compared with those living in the area with the worst community food environment (lowest NEMS-S score). Healthy and fast-food dietary patterns showed no association with the community food environment. In conclusion, the community food environment is a factor associated with the consumption of certain dietary patterns, independent of individual sociodemographic characteristics. Thus, aspects of the community food environment become important in food and nutrition actions and policies aimed at health promotion.