The gut microbiota is a key factor significantly impacting host health by influencing metabolism and immune function. Its composition can be altered by genetic factors, as well as environmental factors such as the host's surroundings, diet, and antibiotic usage. This study aims to examine how the characteristics of the gut microbiota in pigs, used as source animals for xenotransplantation, vary depending on their rearing environment. We compared the diversity and composition of gut microbiota in fecal samples from pigs raised in specific pathogen-free (SPF) and conventional (non-SPF) facilities. The 16S RNA metagenome sequencing results revealed that pigs raised in non-SPF facilities exhibited greater gut microbiota diversity compared to those in SPF facilities. Genera such as Streptococcus and Ruminococcus were more abundant in SPF pigs compared to non-SPF pigs, while Blautia, Bacteroides, and Roseburia were only observed in SPF pigs. Conversely, Prevotella was exclusively present in non-SPF pigs. It was predicted that SPF pigs would show higher levels of processes related to carbohydrate and nucleotide metabolism, and environmental information processing. On the other hand, energy and lipid metabolism, as well as processes associated with genetic information, cell communication, and diseases, were predicted to be more active in the gut microbiota of non-SPF pigs. This study provides insights into how the presence or absence of microorganisms, including pathogens, in pig-rearing facilities affects the composition and function of the pigs' gut microbiota. Furthermore, this serves as a reference for tracing whether xenotransplantation source pigs were maintained in a pathogen-controlled environment.