Blastocystis is a common zoonotic intestinal protozoan and causes a series of gastrointestinal symptoms in humans and animals via the fecal-oral route, causing economic losses and posing public health problems. At present, the prevalence and genetic structure of Blastocystis in sheep and pigs in Shanxi province remains unknown. Thus, the present study collected 492 sheep fecal samples and 362 pig fecal samples from three representative counties in northern, central and southern Shanxi province for the detection of Blastocystis based on its SSU rRNA gene. The results showed that the overall prevalence of Blastocystis in the examined sheep and pigs were 16.26% and 14.09%, respectively. Sequences analyses showed that four known subtypes (ST5, ST10, ST14 and ST30) in sheep and two subtypes (ST1 and ST5) in pigs were detected in this study, with ST5 being the predominate subtype among the study areas. Phylogenetic analysis showed that the same subtypes were clustered into the same branch. This study reveals that sheep and pigs in Shanxi province are hosts for multiple Blastocystis subtypes, including the zoonotic subtypes (ST1 and ST5), posing a risk to public health. Baseline epidemiological data are provided that help in improving our understanding of the role of zoonotic subtypes in Blastocystis transmission.