BackgroundThe gut microbiota of breast-fed and formula-fed infants differ significantly, as do the risks for allergies, gut dysfunction, and upper respiratory tract infections. The connections between breast milk, various formulas, and the profiles of gut bacteria to these childhood illnesses, as well as the mechanisms underlying the effects, are not well understood.MethodsWe investigated distal colon microbiota by 16S RNA amplicon sequencing, morphology by histomorphometry, immune response by cytokine expression, and tryptophan metabolism in a pig model in which piglets were sow-fed, or fed soy or dairy milk-based formula from postnatal day (PND) 2 to 21.ResultsFormula feeding significantly (p < 0.05) altered the colon microbiota relative to the sow feeding. A significant reduction in microbial diversity was noted with formula groups in comparison to sow-fed. Streptococcus, Blautia, Citrobacter, Butrycimonas, Parabacteroides, Lactococcus genera were increased with formula feeding relative to sow feeding. In addition, relative to sow feeding, Anaerotruncus, Akkermansia, Enterococcus, Acinetobacter, Christensenella, and Holdemania were increased in milk-fed piglets, and Biliophila, Ruminococcus, Clostridium were increased in soy-fed piglets. No significant gut morphological changes were noted. However, higher cytokine mRNA expression (BMP4, CCL11, CCL21) was observed in the distal colon of formula groups. Formula feeding reduced enterochromaffin cell number and serotonin, but increased tryptamine levels relative to sow feeding.ConclusionOur data confirm that formula diet alters the colon microbiota and appears to shift tryptophan metabolism from serotonin to tryptamine, which may lead to greater histamine levels and risk of allergies in infants.Electronic supplementary materialThe online version of this article (doi:10.1186/s40168-017-0297-z) contains supplementary material, which is available to authorized users.