The shedding of Escherichia coli O157:H7 and Listeria monocytogenes in the feces of ruminants and the consequential risk to the public and environmental health is well reported. However, the influence of dietary manipulation on the shedding of fecal bacteria is not well understood. This study was conducted to improve understanding of the relationship between dietary feed composition and shedding of E. coli O157:H7 and Listeria spp. in dairy feces. Twelve cows were randomly assigned to four treatment diets of two dietary forage levels: low forage (37.4% dry matter, DM) vs. high forage (53.3% of DM) and two dietary crude protein (CP) levels: low protein (15.2% of DM) vs. high protein (18.5% of DM) in a 4×4 replicated Latin square design with four periods each including a 14 d adaptation and 3 d sample collection periods. Generic E. coli was detected in some of the feed ingredients, such as cotton seed, alfalfa hay, almond, and CaCO3, while Listeria was detected in the alfalfa hay and mineral mix. A significant interaction effect was observed between dietary forage and CP on the presence of fecal E. coli O157:H7 (P=0.01) but not with Listeria. On average, the greatest E. coli O157:H7 level (6.6 log10 CFU/g of feces) was observed from the high forage and high protein diet and the lowest level was 6.1 log10 CFU/g from the low forage and high protein diet. The average Listeria shedding rate was within the range of 1.7–2.3 log10 CFU/g among the dietary forage and CP treatments. For the CP treatments, significantly low levels of Listeria were observed from cows fed the high protein (0.9−1.6 log10 CFU/g) compared to the low protein (1.3–2.1 log10 CFU/g) diet. Considering temporal fluctuations, no significant diurnal pattern was observed for either E.coli O157:H7 or Listeria. In addition, no time of sampling over day by dietary forage or CP content interaction on fecal E.coli O157:H7 or Listeria level was observed. This study showed that diets can influence the shedding of potentially pathogenic bacteria in dairy cow excreta.